Skip to content

Instantly share code, notes, and snippets.

@lucaspar
Last active October 4, 2019 20:54
Show Gist options
  • Save lucaspar/4514ac09826f35f0d9ad5e1305d8bfcb to your computer and use it in GitHub Desktop.
Save lucaspar/4514ac09826f35f0d9ad5e1305d8bfcb to your computer and use it in GitHub Desktop.
[ FIX ] Useful git hotfixes 🔫 :feelsgood:
# 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