Created
March 19, 2021 05:06
-
-
Save DanielLoth/75cca19cc19ed0144f1a53206c429171 to your computer and use it in GitHub Desktop.
Git stuff
This file contains 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
# Assumption: Your remotes are configured as 'origin' (for personal fork) and 'upstream' (for shared git repo). | |
# First, make sure your local workspace is clean | |
git status | |
# If it isn't, either create a WIP branch OR stash your changes | |
# WIP branch: | |
git checkout -b my-current-WIP-19-mar-2021 | |
git add * | |
git commit -m 'WIP' | |
git push --set-upstream origin my-current-WIP-19-mar-2021 | |
# If you are not on master, switch back to master | |
git checkout master | |
# Make a note of the current hash, and additionally check it out into a backup branch that you can push upstream: | |
git rev-parse HEAD # Make a note of this hash | |
git checkout -b master-backup | |
git push --set-upstream origin master-backup # Push backup branch | |
git checkout - # Switch back to master | |
# Now reset to known sha hash | |
git reset --hard <sha hash here> | |
# Now force push to the upstream master branch | |
git push -f upstream master | |
# Now do your build on your build server | |
# Now reset master locally to the backup branch: | |
git reset --hard master-backup | |
# or reset to the sha hash that you recorded: | |
git reset --hard <sha hash> | |
# Now force push again to upstream master: | |
git push -f upstream master | |
# And confirm it has the original hash. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment