Last active
October 4, 2019 20:54
-
-
Save lucaspar/4514ac09826f35f0d9ad5e1305d8bfcb to your computer and use it in GitHub Desktop.
[ FIX ] Useful git hotfixes 🔫
![:feelsgood: :feelsgood:](https://github.githubassets.com/images/icons/emoji/feelsgood.png)
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
# remove files added later in .gitignore | |
git rm -r --cached . | |
git add . | |
git commit -m 'cleared git cache' | |
git push origin master | |
# -------------- CUT HERE -------------- | |
# Fix detached head (and keep changes) | |
# copy hash of latest commit: | |
git log -n 1 | |
git checkout <branch-name-which-changes-will-be-added-to> | |
git branch tmp <copied-hash> | |
git merge tmp | |
# -------------- CUT HERE -------------- | |
# Error "master and * are entirely different commit histories" | |
# this will push all commits from "[BRANCH]" to master | |
git checkout [BRANCH] | |
git branch master [BRANCH] -f | |
git checkout master | |
git push origin master -f |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment