PDA

View Full Version : Basic git commands for layman Linux user



Fli
02-08-2024, 07:09 PM
My layman understanding and notes:

cd /git-folder/ # go to directory where you want to have your copy of a remote git repository

git clone https://github.com/zeronet-conservancy/zeronet-conservancy.git # Now the /git-folder/ became a copy of a remote git repository, so to speak. This is one time command.

git pull origin master # update local repository from origin remote repository

git reset --hard # If for some reason I have made a file modifications and i need to discard these, the command resets the local index and working tree. Any changes to tracked files in the working tree since (remote?) <commit> are discarded.

If developer have made a new branch of their code for testing and asked me to try it. I can run:

git remote add caryoscelus https://github.com/caryoscelus/zeronet-conservancy/ ; git fetch caryoscelus ; git checkout simplified-cors # If I am correct, it adds and downloads remote repository and switch + download defined branch of it

If "git checkout" mentioned above complains "Please commit your changes or stash them before you switch branches.", then i could do "git stash push reported/file/name" to discard that file local changes and repeat "git checkout remote-branch-name"

git branch # show local branches and which one is active.

after testing the branch, i can switch back to previous one:

git switch master # "master" is one of the branches reported to me by earlier command "git branch"