Skip to content

Instantly share code, notes, and snippets.

@DRSDavidSoft
Last active November 6, 2022 09:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DRSDavidSoft/b4cf15a0748f0b3fb00ced63df04d750 to your computer and use it in GitHub Desktop.
Save DRSDavidSoft/b4cf15a0748f0b3fb00ced63df04d750 to your computer and use it in GitHub Desktop.
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
# push local master branch to remote development branch
git push origin master:development
# 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