Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Working with git branches
# fetch upstream branches
## git fetch upstream
# create local branch test from upstream master
git checkout -b test upstream/master
# do some stuff
git add src
git commit -m "did some stuff"
# see changes
git diff HEAD
# create remote branch test in origin and push changes to it
git push -u origin test
# switch back to the local master branch
## git branch -a
git branch master
# list remotes
git remote -v
# change remote url
git remote set-url <remote-name> <remote-url>
# add remote
git remote add origin <remote-url>
git remote add upstream <remote-url>
# remove remote
git remote remove origin
git remote remove upstream
# push to a named remote and branch
git push -u origin master
# pull from origin
git pull origin master
# pull from upstream
git pull upstream master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment