Tuesday, August 9, 2022
HomeWordPress DevelopmentGit Helpful instructions - DEV Group

Git Helpful instructions – DEV Group


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
Enter fullscreen mode

Exit fullscreen mode

  • Revert all native uncommitted modifications:
git checkout .
Enter fullscreen mode

Exit fullscreen mode

  • Revert all uncommitted modifications:
git reset --hard HEAD
Enter fullscreen mode

Exit fullscreen mode

  • Take away all native untracked information, so solely git tracked information stay:
git clear -fdx
Enter fullscreen mode

Exit fullscreen mode

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
Enter fullscreen mode

Exit fullscreen mode

  • Delete the newest commit, preserving the work you have accomplished:
git reset --soft HEAD~1
Enter fullscreen mode

Exit fullscreen mode

rm -rf .git
Enter fullscreen mode

Exit fullscreen mode

  • Take away a file from a Git repository with out deleting it from the native filesystem
git rm --cached .classpath
Enter fullscreen mode

Exit fullscreen mode

  • 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
Enter fullscreen mode

Exit fullscreen mode

  • The right way to revert to origin’s grasp department’s model of file
git checkout origin/grasp filename
Enter fullscreen mode

Exit fullscreen mode

  • 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 .
Enter fullscreen mode

Exit fullscreen mode

If you wish to do the alternative:

git checkout --ours .
git add .
Enter fullscreen mode

Exit fullscreen mode

In pulling

git pull -X theirs
Enter fullscreen mode

Exit fullscreen mode

In a conflicted state by file

git checkout --theirs path/to/file
Enter fullscreen mode

Exit fullscreen mode

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments