-
Notifications
You must be signed in to change notification settings - Fork 18
Git Cheat Sheet
fritogotlayed edited this page Feb 1, 2015
·
3 revisions
Note: With all the commands below you can see the result of your actions (by looking at the commit graph)[https://github.com/DUWS-R-Team/DUWS-R/network] for GitHub or you can run the following command from your Git Bash to get something very similar. git tree = log --graph --decorate --pretty=oneline --abbrev-commit --all
- For SSH
git remote add upstream [email protected]:DUWS-R-Team/DUWS-R.git
- For HTTP
git remote add upstream https://github.com/DUWS-R-Team/DUWS-R.git
-
git checkout master
- Put me on my master branch -
git checkout -b MyNewBranchName
- Create a new branch based off my master
- Updating local
master
-
git fetch upstream
- Let my local know about the changes on DUWS-R -
git checkout master
- Put me on my master branch -
git rebase upstream\master
- Bring my localmaster
up to match the upstreammaster
-
- Updating another branch (perform the above steps first)
-
git checkout MyBranchName
- Put me on my branch -
git rebase master
- Update me to my master- If you have problem here you most likely need to merge or abort
- Some merge tools can be found here
- You can abort by typing
git rebase --abort
- You can merge by following this guide
- If you have problem here you most likely need to merge or abort
-
Cleaning up 'old' branches that have been removed by things such as merging or deleting branches on GitHub
- Letting your local repository know that a branch was deleted from GitHub
git fetch upstream -p
- Removing local branches that have been merged into upstream
-
git branch --merged | grep -v "\*" | egrep -v "master"
-- Prints what branches would be removed if you run the command below containingxargs
-
Make sure you are okay with the branches listed being deleted -- This can be undone by using git's
reflog
but that will not be covered here -
git branch --merged | grep -v "\*" | egrep -v "master" | xargs -n 1 git branch -d
-- Delete the branches that were listed by the first command above.
-