Skip to content

Instantly share code, notes, and snippets.

@asears
Last active January 5, 2020 13:44
Show Gist options
  • Select an option

  • Save asears/7d1c190d59c68a5bf88a180e511ddfe3 to your computer and use it in GitHub Desktop.

Select an option

Save asears/7d1c190d59c68a5bf88a180e511ddfe3 to your computer and use it in GitHub Desktop.
Set Git Upstream and Squash Commits
git remote add upstream [Upstream git URL]

git fetch upstream

git merge upstream/master

git checkout -b "feature-new-stuff"

git push origin feature-new-stuff

git log --graph --decorate --pretty=oneline --abbrev-commit

Squash to 1 commit. https://blog.carbonfive.com/2017/08/28/always-squash-and-rebase-your-git-commits/

git rebase -i HEAD~[NUMBER OF COMMITS]

OR

git rebase -i [SHA]

git push origin branchName --force

git checkout master

git pull origin master

git checkout branchName

git rebase master

Handle any conflicts and make sure your code builds and all tests pass. Force push branch to remote.

git push origin branchName --force

git checkout master

git merge branchName

git push origin master

## Clear local and start from upstream branch again.

git reset --hard upstream/master git reset --hard upstream/develop

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment