Last active
February 18, 2021 12:13
-
-
Save sabuhish/94d59d1f542dffac932673c1ec5cad27 to your computer and use it in GitHub Desktop.
Revisions
-
sabuhish revised this gist
Feb 18, 2021 . 1 changed file with 17 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -104,6 +104,23 @@ git clean -x -d -i removes file in interactive mode. ------Stash------- git stash add changes to stash git stash list to see all the changes git stash pop get last stash , applies the changes and removes the files from the stash git stash apply applies the changes and leaves a copy in the stash ----Revert --- git revert [commit] -
sabuhish revised this gist
Feb 17, 2021 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -66,6 +66,8 @@ git reset b5cd69e unstaging commited code, back to where it was before. By reseting we can make chnages on local repo, we dont lose here anything. We are going back but we are not deleting or cleaning. git reset --soft HEAD^ undo last commit git reset --hard -
sabuhish revised this gist
Feb 17, 2021 . 1 changed file with 66 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -35,6 +35,72 @@ git commit --amend -am "message" replaces another commit, the last commit is orphaned, applies message, and adds new files. ----Reset----- There three types of reset. --hard, --soft, --mixed. git reset defaults to --mixed. git reset commands deafults to --mixed. Easy explanation: Given: - A - B - C (master) git reset --soft A and you will see B and C's stuff in green (staged and ready to commit) git reset --mixed A (or git reset A) and you will see B and C's stuff in red (unstaged and ready to be staged (green) and then committed) git reset --hard A and you will no longer see B and C's changes anywhere (will be as if they never existed) git reset HEAD git status -s if you dont want changes, go back but does not cleanup. unstaging the chnages. This before adding changes (for commits does not apply). How do I get my repo back to the state it was in before I started making changes without losing my changes? git reset info.txt unstage info.txt removing file from being staged, untrack the file. git reset b5cd69e unstaging commited code, back to where it was before. By reseting we can make chnages on local repo, we dont lose here anything. We are going back but we are not deleting or cleaning. git reset --hard The “git reset –hard” operation is considered the most effective operation if you wish to entirely get rid of your last commit. It means that when you perform this operation, the head of your file will change, i.e., it will no longer be pointing to your last commit. Not only this, but it will also clear out your last commit from your index and even change your current working directory. what it does head reseted to last commit where it was before, your changes will be lost will start from begining. git reset [commit] git reset c9f17d2 --hard head will be c9f17d2 at your branch, bracnh will be back to here (c9f17d2) git reset --soft HEAD~1 If you do find yourself in the situation where you’ve accidentally committed some messy code, you can do a “soft” reset. This means that the code appears as if it has not been committed yet. Then you can tidy up your code in your IDE before making a cleaner commi. ele bil bir commit dala qaytarir git reset --soft HEAD~2 takes back 2 commits before does not clean your code. git reset --hard HEAD~1 This type of reset essentially erases your last commit. You should be very careful about performing hard resets, especially if you push your branch, as there is no way to restore your commit git clean -x -d -i removes file in interactive mode. ----Revert --- -
sabuhish revised this gist
Feb 17, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -184,4 +184,4 @@ resources: https://davidzych.com/difference-between-git-reset-soft-mixed-and-hard/ http://onlywei.github.io/explain-git-with-d3/#fetch http://onlywei.github.io/explain-git-with-d3/#zen https://git-scm.com/book/az/v2 -
sabuhish revised this gist
Feb 17, 2021 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -183,4 +183,5 @@ to delete tag on remote resources: https://davidzych.com/difference-between-git-reset-soft-mixed-and-hard/ http://onlywei.github.io/explain-git-with-d3/#fetch http://onlywei.github.io/explain-git-with-d3/#zen -
sabuhish revised this gist
Feb 17, 2021 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -180,4 +180,7 @@ git push origin :tag_name to delete tag on remote resources: https://davidzych.com/difference-between-git-reset-soft-mixed-and-hard/ http://onlywei.github.io/explain-git-with-d3/#fetch -
sabuhish renamed this gist
Feb 17, 2021 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
sabuhish created this gist
Feb 17, 2021 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,183 @@ ----Branch---- git checkout - moves to the previous branch where you were before. git diff master..my-branch see the difference between branches git branch -m test In order to rename a current branch git branch -D headtestbracnh Hard deleting the branch ---Amend---- git commit --amend git amend is useful for changing the commit message or changing your last commit files changes, rewrite history. Don't do this on the master. do it somewhere on your local branch, because it will rewrite the history again can cause conflict. This command will create another commit git commit --amend -m "message of my commit changed " applies message git commit --amend -am "message" replaces another commit, the last commit is orphaned, applies message, and adds new files. ----Revert --- git revert [commit] undo the commit and creates a new commit. ---REBASING---- Ultimately main reason to do this to have linear commit history. To make look like we never made of branch history. Keeps our commit any more ordered fashion. one solid linear history. git checkout -b Reabase1 git rebase master git checkout master git merge Reabase1 ----LOG---- git log --oneline shows git history of all commits that is only reachable ones. git log --pretty=oneline shows entire commit git log --all --grep='loca*' finds all commits regarding to the given message git log --author="Sabuhi" get all logs from author Sabuhi git reflog git log -p git log --pretty=oneline --abbrev-commit git log --oneline --graph --decorate decorate the logs git reflog HEAD@{100} logs from 100 to end git reflog HEAD@{3.days.ago} git reflog HEAD@{2.weeks.ago} git reflog master git difftool HEAD@{4} HEAD@{5} git reflog expire --expire-unreachable=now --all git gc --prune=now Garbage collector for git history -----Tools------ git merge master While merging branch, if you face conflict then mergetool will be superman for you git mergetool git difftoll [commmit] [ commmit] git difftool HEAD@{1.min.ago} HEAD@{1.day.ago} ----Config && ALias---- git config --global -e Global config for your git. git config --global --list To get your current config list git config --global alias.onelinegraph 'log --oneline --graph --decorate' setting config git config --global alias.expireunreachablenow 'reflog expire --expire-unreachable=now --all' setting config git config --global alias.gcunreachable 'gc --prune=now' ---TAG--- Two types of tags: lightweight and annotated tags a lightweight tag is like a bookmark to a specific place that you'd want to use if you want to get back to that spot and an annotated tag allows you to make a tag that you can put your information about who did it what all the state of the thing was when it was done. git tag gets all tags git checkout tag_name checkout to the tag_name git tag mytag this lightweight tag git tag -a onmasterannotatde -m "say this" this one is annotated tag git show onmasterannotatde show commits on a specific tag git tag -d tag_name To delete a tag git push --tags To push all your tags git push origin :tag_name to delete tag on remote