Last active
November 19, 2024 18:18
-
Star
(446)
You must be signed in to star a gist -
Fork
(91)
You must be signed in to fork a gist
-
-
Save nepsilon/156387acf9e1e72d48fa35c4fabef0b4 to your computer and use it in GitHub Desktop.
Revisions
-
nepsilon revised this gist
Aug 2, 2016 . 1 changed file with 2 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 @@ -18,7 +18,7 @@ git push origin master --force ``` We edit the message like just above. But need to `--force` the push to update the remote history. ⚠️ **But! Force pushing your commit after changing it will very likely prevent others to sync with the repo, if they already pulled a copy. You should first check with them.** ## Not pushed + old commit: ```bash @@ -39,4 +39,4 @@ Then force push the commit: git push origin master --force ``` ⚠️ **But! Remember re-pushing your commit after changing it will very likely prevent others to sync with the repo, if they already pulled a copy. You should first check with them.** -
nepsilon revised this gist
Jul 6, 2016 . No changes.There are no files selected for viewing
-
nepsilon revised this gist
Jul 6, 2016 . 1 changed file with 2 additions 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 @@ -38,4 +38,5 @@ Then force push the commit: ```bash git push origin master --force ``` ⚠️ **But! Remember re-pushing your commit after changing it will very likely prevent others to sync with the repo, if they already pulled a copy. You shoul first check with them.** -
nepsilon revised this gist
Jul 6, 2016 . 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 @@ -17,6 +17,7 @@ git commit --amend git push origin master --force ``` We edit the message like just above. But need to `--force` the push to update the remote history. ⚠️ **But! Force pushing your commit after changing it will very likely prevent others to sync with the repo, if they already pulled a copy. You shoul first check with them.** ## Not pushed + old commit: -
nepsilon revised this gist
Jul 6, 2016 . 1 changed file with 3 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 @@ -17,7 +17,7 @@ git commit --amend git push origin master --force ``` We edit the message like just above. But need to `--force` the push to update the remote history. ⚠️ **But! Force pushing your commit after changing it will very likely prevent others to sync with the repo, if they already pulled a copy. You shoul first check with them.** ## Not pushed + old commit: ```bash @@ -36,4 +36,5 @@ Edit your message with the same 3 steps process as above (`rebase -i`, `commit - Then force push the commit: ```bash git push origin master --force ``` ⚠️ **But! Remember re-pushing your commit after changing it will very likely prevent others to sync with the repo, if they already pulled a copy. You shoul first check with them. ** -
nepsilon revised this gist
Jul 5, 2016 . No changes.There are no files selected for viewing
-
nepsilon revised this gist
Jul 4, 2016 . 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 @@ -1,7 +1,7 @@ # How to change your commit messages in Git? At some point you’ll find yourself in a situation where you need edit a commit message. That commit might already be pushed or not, be the most recent or burried below 10 other commits, but fear not, git has your back 🙂. ## Not pushed + most recent commit: ```bash -
nepsilon revised this gist
Jul 4, 2016 . 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 @@ -31,7 +31,7 @@ git rebase --continue ``` Rebase opened your history and let you pick what to change. With edit you tell you want to change the message. Git moves you to a new branch to let you --amend the message. git rebase --continue puts you back in your previous branch with the message changed. ## Already pushed + old commit: Edit your message with the same 3 steps process as above (`rebase -i`, `commit --amend`, `rebase --continue`). Then force push the commit: ```bash -
nepsilon revised this gist
Jul 4, 2016 . 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 @@ # How to change your commit messages in Git? At some point you’ll find yourself in a situation where you need edit a commit message. That commit might already be pushed or not, be the most recent, or burried below 10 other commits, but fear not, git has your back 🙂. -
nepsilon created this gist
Jul 4, 2016 .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,37 @@ At some point you’ll find yourself in a situation where you need edit a commit message. That commit might already be pushed or not, be the most recent, or burried below 10 other commits, but fear not, git has your back 🙂. ## Not pushed + most recent commit: ```bash git commit --amend ``` This will open your `$EDITOR` and let you change the message. Continue with your usual `git push origin master`. ## Already pushed + most recent commit: ```bash git commit --amend git push origin master --force ``` We edit the message like just above. But need to `--force` the push to update the remote history. Note that if others have already pulled your commits this may come with undesired effects. ## Not pushed + old commit: ```bash git rebase -i HEAD~X # X is the number of commits to go back # Move to the line of your commit, change pick into edit, # then change your commit message: git commit --amend # Finish the rebase with: git rebase --continue ``` Rebase opened your history and let you pick what to change. With edit you tell you want to change the message. Git moves you to a new branch to let you --amend the message. git rebase --continue puts you back in your previous branch with the message changed. ### Already pushed + old commit: Edit your message with the same 3 steps process as above (`rebase -i`, `commit --amend`, `rebase --continue`). Then force push the commit: ```bash git push origin master --force ```