Skip to content

Instantly share code, notes, and snippets.

/git.md Secret

Created March 6, 2017 20:10
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 anonymous/4607b0f74493c5b8be0c7369d21e5b7e to your computer and use it in GitHub Desktop.
Save anonymous/4607b0f74493c5b8be0c7369d21e5b7e to your computer and use it in GitHub Desktop.

Pointing to upstream/develop

If you already have your develop branch pointing to your origin/develop, change it so that it points to upstream:

git branch --set-upstream-to upstream/develop develop

If it does not already point to upstream, let's make it do so:

git checkout -b develop upstream/develop

Keep your upstream up-to-date with

git checkout develop && git pull

New features

There are probably better workflows:

Create a feature branch

git checkout develop && git pull
git checkout -b feature develop

... commit some stuff ...

Push feature branch

Push feature branch to origin:

git push -u origin feature

Keep feature branch up-to-date

To get the most recent changes to develop into your branch:

git checkout develop && git pull
git checkout feature
git rebase develop

Fix any conflicts:

git add -A . # stage all changes
git rebase --continue # continue with rebase

Update remote tracking branch:

git push -f # rewrites history for anyone else that's pulled

Optionally squash commits

If you'd like to squash changes before you commit -- only if you've rebased and not merged develop's changes.

git rebase -i <commit-before-your-first-commit-on-feature>

Then pick the first and squash the rest. Update the commit message:

Update remote tracking branch:

git push -f # rewrites history for anyone else that's pulled

Finished branch

Submit PR

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