Useful Git Commands - struct-by-lightning/wpi-suite GitHub Wiki
Clone
Description
This command is used to copy a remote repository on the github servers to a local machine. It automatically sets up a remote under the name "origin".
Usage
$ git clone [repository SSH/SHTTP/SVN address]
Fetch
Description
This command is used to update the local repository with the information about the current state of the remote repository, and all of its branches.
Usage
$ git fetch origin
Where origin is the remote name of the remote repository.
Merge
Description
This command merges the named branch into the currently active branch. This will not necessarily work if there are conflicts (the same line is changed in both branches). However, git will markup the changed file to make the changed portion obvious, and manually fixing the change is generally as easy as deleting one of the versions of that line in the merged file, and removing the markup tags.
A useful option for this command is --no-ff, which prevents fast-forwarding. This allows git to maintain the previous commit structure, making reverting easy.
Usage
$ git merge --no-ff other_branch
Pull
Description
Pull combines two of the previous commands, fetch and merge. When you call pull on a branch, it fetches the information about the named branch, and merges it into the current branch.
Usage
$ git pull other_branch
Commit
Description
This is the command you will be using the most often. It is used to commit changes you have made to a repository. When you call this command, you will be brought to an editor to enter the a commit message. A good guideline for commit messages is this one by Linus Torvalds, located at line 92 of the Subsurface Readme.
A useful option for this command is -a (or --all) which serves the same purpose as the "add all" command. It adds all changes made to the commit.
Usage
$ git commit -a
Push
Description
Push is the command used to update the remote repository with local commits. When you use the push command, all new commits are sent to the specified remote repository.
Usage
$ git push origin this_branch
Where origin is the remote name and this_branch is the branch the you wish to push the changes to. You should generally only push the changes to the modified branch.