git pull origin master --allow-unrelated-historiesgit cherry-pick -x <sha>git log -S "string to find"git push origin mybranch --force-with-leasegit commit --amend -m 'xxxxxxx'git show -s --format=%ci HEADgit reset HEAD^ --hard
git push --force-with-lease [remote] [branch]git reset --soft HEAD@{1}git commit --amend -m "New commit message" git add file
git commit --amend --no-editgit rm -r one-of-the-directories
git commit -m "Remove duplicated directory"
git push origin <your-git-branch>git rm -r --cached myFoldergit branch --no-merged mastergit branch -a --no-merged mastergit add -pgit checkout -b <branch> <SHA1_OF_COMMIT>(master)$ git reflog
ab7555f HEAD@{0}: pull origin wrong-branch: Fast-forward
c5bc55a HEAD@{1}: checkout: checkout message goes here
Simply reset your branch back to the desired commit:
$ git reset --hard c5bc55a(master)$ git reflog
69204cd HEAD@{0}: checkout: moving from my-branch to master
4e3cd85 HEAD@{1}: commit: foo.txt added
69204cd HEAD@{2}: checkout: moving from master to my-branch
(master)$ git checkout -b my-branch-help
Switched to a new branch 'my-branch-help'
(my-branch-help)$ git reset --hard 4e3cd85
HEAD is now at 4e3cd85 foo.txt added
(my-branch-help)$ ls
README.md foo.txtgit log -U -m --simplify-merges --merges -- a.txtIf solution is to accept local/our version, run:
git checkout --ours PATH/FILEIf solution is to accept remote/other-branch version, run:
git checkout --theirs PATH/FILE# create a new branch from the current state of master
git branch some-new-branch-name
# remove the commit from the master branch
git reset HEAD~ --hard
git checkout some-new-branch-name
# your commit lives in this branch now :)Solution 1
# undo the last commit, but leave the changes available
git reset HEAD~ --soft
git stash
# move to the correct branch
git checkout name-of-the-correct-branch
git stash pop
git add . # or add individual files
git commit -m "your message here"
# now your changes are on the correct branchSolution 2
git checkout name-of-the-correct-branch
# grab the last commit to master
git cherry-pick master
# delete it from master
git checkout master
git reset HEAD~ --hard