Our mind is best at processing information than storing it. In order that’s why I am creating this doc with one of many helpful however possibly not so frequent instructions to get the very best for this glorious software
- Unstage all information you might need staged with git add
git reset
- Revert all native uncommitted modifications:
git checkout .
- Revert all uncommitted modifications:
git reset --hard HEAD
- Take away all native untracked information, so solely git tracked information stay:
git clear -fdx
WARNING: -x will even take away all ignored information, together with ones specified by .gitignore! It’s possible you’ll need to use -n for a preview of information to be deleted.
- Delete all branches besides the primary one
git department | grep -v "principal" | grep -v "grasp" | xargs git department -D
- Delete the newest commit, preserving the work you have accomplished:
git reset --soft HEAD~1
rm -rf .git
- Take away a file from a Git repository with out deleting it from the native filesystem
git rm --cached .classpath
- In case you have a sequence of commits
… – Commit1 – Commit2 – … Commit5 <- HEAD
To squash Commit2 to Commit5 right into a single commit, you possibly can reset your department to Commit1 after which commit once more:
git reset --soft Commit1
git commit
- The right way to revert to origin’s grasp department’s model of file
git checkout origin/grasp filename
- Resolve Git merge conflicts in favor of their modifications throughout a pull
In a conflicted state, and also you need to simply settle for all of theirs:
git checkout --theirs .
git add .
If you wish to do the alternative:
git checkout --ours .
git add .
In pulling
git pull -X theirs
In a conflicted state by file
git checkout --theirs path/to/file