Last active
July 26, 2018 11:14
-
-
Save volkanbicer/19e3accf54b00f2abc1c6ba4ea8ec7cc to your computer and use it in GitHub Desktop.
Advanced git tips
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Move commit from one branch to another. | |
git checkout dev | |
git cherry-pick 12345 | |
git checkout master | |
git reset 12345 | |
# Git reset | |
PS: Try not to change the git history. Use this on local commits | |
--soft reset commit, but keep the changes in staging area | |
--mixed default option. Reset the commit and keep the changes aren't in staging area | |
--hard, reversed all the tracked files back to the state that they were but it leaves any untracked files alone | |
git reset --hard HEAD@{1} | |
# git clean -df (Cleans directories and files) | |
# git --amend (Creates another commit) | |
# Git revert | |
Create new commit which resed previous commit. This won't change the commit history. | |
git revert 12345 | |
# git reflog | |
Shows the all logs. Use case if you hard reset your commit and loose all the changes then you can use this command. | |
When you see the commit hash then | |
git checout 12345 (This detach from branch) | |
git branch backup | |
git checkout master | |
In this case your changes will be on the backup branh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment