Last active
June 10, 2020 10:19
-
-
Save bendilley/0b6cfb33430ccf9ebc2d4c79e34496e6 to your computer and use it in GitHub Desktop.
git workflow with backups
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Note that this workflow requires that the default push is to an explicit upstream: | |
git config --global push.default upstream | |
# create a personal fork of the origin repo and make it a 2nd remote: | |
git remote add fork [email protected]:myusername/cool_project.git | |
# start work on your stuff: | |
git checkout -b new-feature | |
# when you get to a point where losing your work would make you very sad: | |
git commit -a # or stage only what you want to keep of course | |
git push -u fork new-feature # fork is now the upstream remote for this branch | |
# keep backing up as you stage the good stuff | |
git commit --amend # why not improve that commit message too | |
git push --force-with-lease | |
# when you get to a point where you're ready to create a PR | |
git push -u origin new-feature # now origin is the upstream | |
# oops, that PR needs a lot more work! | |
# let's go back to the fork for a bit | |
git push -u fork new-feature | |
# rinse, repeat | |
# don't need that backup anymore? | |
git push fork :new-feature |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment