Version: CS4260 (2015)
man git <command>
All branches can be see with the following command. git branch -a
The output will appear as:
<branch 1>
<branch 2>
remote/<branch 1>
Will have just a name and appear as
<branch name>
Are indicated by the leading word, "remote", and appear as follows.
remote/<branch name>
This command will only update your remote branches. Local branches are not touched. The "-a" is all, and the -p is prune. Prune means to remove remote banches that no longer exsist in the remote repository.
git fetch -ap
A git pull
will do a git fetch
and git merge
, so to update a
local branch use the following command. This must be done to every local branch.
git checkout <branch a>
git pull origin <branch a>
Do not confuse this with the following command, becuase it will fetch and merge the remote's "master" into the branch you are currently working on.
git checkout <branch a>
git pull origin master
The above command is useful to help update the branch you are working, it should make merging a little easier. This is totally dependent on your work-flow (use of git).
Cloning/copying the repo to your machine.
git clone < repo address >
This can only be done if no changes have been made.
git checkout <branch name a>
git branch <branch name a>
Also if you switched to a branch that does not contain files from the prvious branch, the branch you switch to will now need to be cleaned. Use the following command. See Undo Changes before staged.
There are two ways this can be done. The following command create a branch based from the branch you are curently working on and switches to the newly created branch.
git checkout -b feature/<something your working on>
To create a new brach based of anothe branch and switches to the newly created branch:
git checkout -b <your branch name> <some local or remote branch>
Now your ready to make changes to the code.
git diff command order matters, generaly arguments should be as follows:
git diff <old> <new>
For a specific file
git diff <name of file or path and name of file>
For all files
git diff
git diff <branch name a> <branch name b>
git diff HEAD^ HEAD
insert instuctions here
Commits can be see a set of files saved at a particular moment.
When changes are complete and you would like to save at that moment.
- Stage All Changes For Commit
git add -A .
- Stage a File For Commit
git add <file name or path and file name>
- Stage a Directory For Commit
git add <directory name or path and directory name>
git commit -m "<your message>"
git log -1
Once a new commit has been created you are now ready to push your code to the remote repository.
git push origin <branch name a>
Always check the remotes website to make sure you changes were pushed.
Basic Git commands
https://confluence.atlassian.com/display/STASH/Basic+Git+commands
Tutorial on how to manipulate commits
http://pcottle.github.io/learnGitBranching/
Git flow
http://nvie.com/posts/a-successful-git-branching-model/
Pro Git