Skip to content

Instantly share code, notes, and snippets.

@maicher
Last active June 14, 2017 13:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maicher/794eea6ebe72dc6852582a66434ab7bb to your computer and use it in GitHub Desktop.
Save maicher/794eea6ebe72dc6852582a66434ab7bb to your computer and use it in GitHub Desktop.
Some useful git commands
# Managing own fork
### Configure upstream
git remote -v
git remote add upstream git@github.com:wimdu/wimdu.git
### Syncing to upstream
git checkout master
git fetch upstream master
git reset --hard upstream/master
git push origin master --force
### Rebasing branch
git checkout -b <branch>
git rebase master
git push origin <brach> --force
# Work on someone's elses fork
### Configure
git remote add agudulin git@github.com:agudulin/wimdu.git
git fetch agudulin
git checkout --track agudulin/branch_name
### Syncing
git reset --hard agudulin/branch_name
or
git pull agudulin branch_name --rebase
### Pushing
git checkout branch_name
git push agudulin branch_name
# Merging
git co master
git reset --hard upstream/master
git push origin master --force
git co <branch>
git rebase master
git push origin <brach> --force
git merge <branch> --no-ff
git push upstream master
# Extras
git rebase -i HEAD~4
# More reading
- https://help.github.com/articles/configuring-a-remote-for-a-fork/
- https://gist.github.com/Chaser324/ce0505fbed06b947d962
- https://git-scm.com/doc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment