Skip to content

Latest commit

 

History

History
88 lines (71 loc) · 2.75 KB

README.md

File metadata and controls

88 lines (71 loc) · 2.75 KB

Life and Time Saver Git Commands 🚀

A repository that contains life and timer saver git commands; rollback, revert, etc. (in-progress)


How to delete all local git branches?

git branch --list | grep -v 'master' | xargs git branch -D

How to undo the last commit from a remote git repository?

git reset HEAD^
git push origin +HEAD

How to revert merge?

# create new branch for being safe.
git revert -m 1 <MERGE_COMMIT_ID>
git push

How to revert conflicted merge?

git merge --abort

How to Checkout/Update a Single File From Remote Origin Master?

git checkout origin/<branch-name> -- <path-to-file>

How to pick a commit and apply current branch from another branch? (cherry-pick)

git cherry-pick <commit_id>

How to remove untracked files?

git ls-files --others --exclude-standard | xargs rm

How to add a message to stash?

git stash save "Your stash message"

How to bring nth record from the stash list without removing it?

git stash apply {n} # n is optional, from nth history.

How to bring last entry to the stash list and remove?

git stash pop 

How to delete a stash record from the list?

git stash drop 

How to move latest changes to stash with different branch?

git stash branch <new-branch-name>

How to visualize all git logs?

git log --oneline --graph -decorate --all