Skip to content

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

License

Notifications You must be signed in to change notification settings

yusufyilmazfr/life-saver-git-commands

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 

Repository files navigation

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 Git cherry-pick only changes to certain files?

# cherry-pick -n (--no-commit) which lets you inspect (and modify) the result before committing.
git cherry-pick -n <commit>

# unstage everything
git reset HEAD

# stage the modifications you do want
git add <path>

# make the work tree match the index
# (do this from the top level of the repo)
git checkout .

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

About

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

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published