Last active
June 2, 2021 09:14
-
-
Save nrninsane/eb7d0fb69902072732d7a91e61d41f1a to your computer and use it in GitHub Desktop.
Revisions
-
nrninsane revised this gist
Jun 2, 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 @@ -15,7 +15,7 @@ git stash save "split this up into multiple commits" - ```git stash apply``` - modify lines, - git add, - git commit 3. get back the original state of the rebase step ``` -
nrninsane revised this gist
Apr 13, 2021 . No changes.There are no files selected for viewing
-
nrninsane revised this gist
Apr 13, 2021 . 1 changed file with 10 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 @@ -0,0 +1,10 @@ from https://coderwall.com/p/euwpig/a-better-git-log configure ```bash git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit" ``` usages: - `git lg` - `git lg -p` to see line changes -
nrninsane revised this gist
Oct 8, 2020 . 1 changed file with 5 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 @@ -7,3 +7,8 @@ git reflog ``` git cherry-pick <hash> ``` - to cherry-pick without automatically committing ``` git chery-pick -n <hash> ``` -
nrninsane revised this gist
Oct 8, 2020 . 1 changed file with 9 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 @@ -0,0 +1,9 @@ - to find recent dangling commit ``` git reflog ``` - this dangling commit can be inserted back ``` git cherry-pick <hash> ``` -
nrninsane revised this gist
Sep 14, 2020 . 1 changed file with 7 additions and 2 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 @@ -1,13 +1,18 @@ Tip: practice this on a throwaway project to get a better grasp. 0. create a backup ``` git branch backup-in-case-of-screwup ``` 1. to split up the commit of current rebase step ``` git reset HEAD^ git stash save "split this up into multiple commits" ``` 2. make the changes - ```git stash apply``` - modify lines, - git add, - git commit (first one has to be ```--amend```!) -
nrninsane revised this gist
Sep 14, 2020 . 1 changed file with 6 additions and 4 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 @@ -2,13 +2,15 @@ Tip: practice this on a throwaway project to get a better grasp. 1. to split up the commit of current rebase step ``` git reset HEAD^ git stash save "<myStash>" ``` 2. make the changes - ```git stash apply <myStash>``` - modify lines, - git add, - git commit (first one has to be ```--amend```!) 3. get back the original state of the rebase step ``` -
nrninsane revised this gist
Sep 11, 2020 . No changes.There are no files selected for viewing
-
nrninsane revised this gist
Sep 11, 2020 . 4 changed files with 60 additions and 70 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 @@ -0,0 +1,18 @@ Note: only rebase local branches, **NEVER REBASE A REMOTE BRANCH**. 1. create backup to preserve original commit tree ``` git branch myBackup ``` 2. get list of commits and their SHA ``` git --no-pager log --oneline ``` 3. start interactive rebase on targetSHA ``` git rebase -i <targetSHA>^ ``` 4. determine what to do with each commit & continue: keep, edit, etc. (git will show you the options) 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 @@ -1,70 +0,0 @@ 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,33 @@ Tip: practice this on a throwaway project to get a better grasp. 1. to split up the commit of current rebase step ``` git stash save "<myStash>" git reset HEAD^ ``` 1. make the changes ```git stash apply <myStash>``` modify lines, git add, git commit 3. get back the original state of the rebase step ``` git stash apply <myStash> ``` 4. repeat until nothing to commit 5. if you are done with the current rebase step ``` git rebase --continue ``` **if you want to abort rebase** ``` git rebase --abort ``` **if rebase finished and it was not what you wanted** ``` git reset myBackup --hard ``` 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,9 @@ - to include untracked files ``` git stash save --include-untracked "<myDescription>" ``` - to include everything, even files/folders in .gitignore ``` git stash --all "<myDescription>" ``` -
nrninsane revised this gist
Aug 3, 2020 . 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 @@ -39,7 +39,7 @@ Tip: practice this on a throwaway project to get a better grasp. 1. to split up the commit of current rebase step ``` git stash save "<myStash>" git reset HEAD^ ``` -
nrninsane revised this gist
Aug 3, 2020 . 1 changed file with 27 additions and 9 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 @@ -3,23 +3,33 @@ Most of it is straightforward - to include untracked files ``` git stash save --include-untracked "<myDescription>" ``` - to include everything, even files/folders in .gitignore ``` git stash --all "<myDescription>" ``` # Basic rebasing Note: only rebase local branches, **NEVER REBASE A REMOTE BRANCH**. 1. create backup to preserve original commit tree ``` git branch myBackup ``` 2. get list of commits and their SHA ``` git --no-pager log --oneline ``` 3. start interactive rebase on targetSHA ``` git rebase -i <targetSHA>^ ``` 4. determine what to do with each commit & continue: keep, edit, etc. (git will show you the options) @@ -38,15 +48,23 @@ git reset HEAD^ modify lines, git add, git commit 3. get back the original state of the rebase step ``` git stash apply <myStash> ``` 4. repeat until nothing to commit 5. if you are done with the current rebase step ``` git rebase --continue ``` **if you want to abort rebase** ``` git rebase --abort ``` **if rebase finished and it was not what you wanted** ``` git reset myBackup --hard ``` -
nrninsane revised this gist
Aug 3, 2020 . 1 changed file with 10 additions and 10 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 @@ -3,23 +3,23 @@ Most of it is straightforward - to include untracked files ```git stash save --include-untracked "<myDescription>"``` - to include everything, even files/folders in .gitignore ```git stash --all "<myDescription>"``` # Basic rebasing Note: only rebase local branches, **NEVER REBASE A REMOTE BRANCH**. 1. create backup to preserve original commit tree ```git branch myBackup``` 2. get list of commits and their SHA ```git --no-pager log --oneline``` 3. start interactive rebase on targetSHA ```git rebase -i <targetSHA>^``` 4. determine what to do with each commit & continue: keep, edit, etc. (git will show you the options) @@ -34,19 +34,19 @@ git reset HEAD^ ``` 1. make the changes ```git stash apply <myStash>``` modify lines, git add, git commit 3. get back the original state of the rebase step ```git stash apply <myStash>``` 4. repeat until nothing to commit 5. if you are done with the current rebase step ```git rebase --continue``` **if you want to abort rebase** ```git rebase --abort``` **if rebase finished and it was not what you wanted** ```git reset myBackup --hard``` -
nrninsane revised this gist
Aug 3, 2020 . 2 changed files with 52 additions and 52 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 @@ -1,52 +0,0 @@ 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,52 @@ # Stashing Most of it is straightforward - to include untracked files `git stash save --include-untracked "<myDescription>"` - to include everything, even files/folders in .gitignore `git stash --all "<myDescription>"` # Basic rebasing Note: only rebase local branches, **NEVER REBASE A REMOTE BRANCH**. 1. create backup to preserve original commit tree `git branch myBackup` 2. get list of commits and their SHA `git --no-pager log --oneline` 3. start interactive rebase on targetSHA `git rebase -i <targetSHA>^` 4. determine what to do with each commit & continue: keep, edit, etc. (git will show you the options) ## Splitting up a commit Tip: practice this on a throwaway project to get a better grasp. 1. to split up the commit of current rebase step ``` git stash save myStash git reset HEAD^ ``` 1. make the changes `git stash apply <myStash>` modify lines, git add, git commit 3. get back the original state of the rebase step `git stash apply <myStash>` 4. repeat until nothing to commit 5. if you are done with the current rebase step `git rebase --continue` **if you want to abort rebase** `git rebase --abort` **if rebase finished and it was not what you wanted** `git reset myBackup --hard` -
nrninsane revised this gist
Aug 3, 2020 . 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 @@ -1,3 +1,5 @@ NOTE: ONLY REBASE A LOCAL BRANCH, **NEVER REBASE A REMOTE BRANCH** ########################################## # NOTE # ########################################## -
nrninsane revised this gist
Mar 15, 2020 . 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 @@ -24,6 +24,7 @@ git stash save myStash git reset HEAD^ ### make the changes git stash apply myStash ### modify lines, git add, git commit ### get back the original state of the rebase step -
nrninsane revised this gist
Mar 15, 2020 . No changes.There are no files selected for viewing
-
nrninsane revised this gist
Mar 15, 2020 . 1 changed file with 8 additions and 8 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 @@ -1,11 +1,11 @@ ########################################## # NOTE # ########################################## # # # ONLY REBASE A LOCAL BRANCH # # NEVER EVER EVER REBASE A REMOTE BRANCH # # # ########################################## # create backup to preserve original commit tree git branch myBackup -
nrninsane revised this gist
Mar 15, 2020 . 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 @@ -10,7 +10,7 @@ # create backup to preserve original commit tree git branch myBackup # get list of commits and their SHA git --no-pager log --oneline # start interactive rebase on targetSHA -
nrninsane renamed this gist
Mar 15, 2020 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
nrninsane renamed this gist
Mar 15, 2020 . 1 changed file with 4 additions and 3 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 @@ -41,8 +41,9 @@ git rebase --abort #if rebase finished and it was not what you wanted git reset myBackup --hard ################ # Tip: # Practice this on some nonsensical files # to get a sense for this process -
nrninsane created this gist
Mar 15, 2020 .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,48 @@ ############################################## # NOTE # ############################################## # # # ONLY REBASE ON A LOCAL BRANCH # # NEVER EVER EVER DO THIS ON A REMOTE BRANCH # # # ############################################## # create backup to preserve original commit tree git branch myBackup # get list of commits git --no-pager log --oneline # start interactive rebase on targetSHA git rebase -i targetSHA^ # determine what to do with each commit & continue # keep, edit, etc. (git will show you the options) ## if you want to split up the commit of current rebase step git stash save myStash git reset HEAD^ ### make the changes ### modify lines, git add, git commit ### get back the original state of the rebase step git stash apply myStash ### repeat until nothing to commit ### (go to line 16) ## if you are done with the current rebase step git rebase --continue ## if you want to abort rebase git rebase --abort #if rebase finished and it was not what you wanted git reset myBackup --hard