Skip to content

Instantly share code, notes, and snippets.

@ymauray
Created December 12, 2017 09:34
Show Gist options
  • Save ymauray/d3a11182dbe6e7d7f3d5f2b2ba4e086a to your computer and use it in GitHub Desktop.
Save ymauray/d3a11182dbe6e7d7f3d5f2b2ba4e086a to your computer and use it in GitHub Desktop.
Usefull git commands and workflow

Usefull git commands and workflow

Set "vi" as the default editor

git config --global core.editor "vi"

Prepare a branch to work on fixes (assuming master is always a clone of upstream/master) :

git fetch --all
git checkout master
git merge upstream/master
git push
git branch fixes
git checkout fixes

Prepare the branch to create a pull request :

git fetch --all
git merge upstream/master
git add .
git commit -m "A clever commit message"
git push -u origin fixes

Clean-up after the pull request is merged :

git fetch --all
git checkout master
git merge upstream/master
git push
git branch -d fixes
git push origin --delete fixes

Rebase any development branches :

git checkout featurebranch
git rebase master

In case the pull request was squashed and not merged :

git fetch --all
git checkout master
git reset --hard upstream/master
git push --force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment