Rewriting Commit Messages in Git

  Рет қаралды 64,693

Eric Phetteplace

Eric Phetteplace

Күн бұрын

Пікірлер: 54
@vertexforger
@vertexforger 2 жыл бұрын
People like you deserve all the praise in the world. You are here to do one thing and one thing only and it is exactly what you did. No bullshit talking for 30 minutes, straight to the point and easy to follow. Much appreciated.
@erichepperlewp
@erichepperlewp 3 жыл бұрын
This was exactly what I needed. In the Git manual online it isn't very clear to me that my editor will pop up twice. You made this very clear and painless. Thank you!
@stephanie_ong
@stephanie_ong 3 жыл бұрын
Awesome video! This was a great refresher for me who has not used rename in a while.
@ahmeda5110
@ahmeda5110 4 жыл бұрын
This really helped me so much. Thank you Eric. I never new the command :wq existed and was wondering how on earth I could continue in VIM with the rebase. Much appreciated.
@ismailkassim6325
@ismailkassim6325 4 жыл бұрын
At 2:13 when you wrote the commit, how did you get to the buttom? edit* Fix the issue. Press shift and colon( : ) at the same time -> shift + :
@ItsEverythingElse
@ItsEverythingElse 6 жыл бұрын
So you have to count back how many commits you need to go? That's really special.
@hyfytale9577
@hyfytale9577 5 жыл бұрын
You can write 'git rebase -i ', where takes you from where you'd like to rebase from instead of counting commits.
@jaydraws2019
@jaydraws2019 4 жыл бұрын
God level tutorial. You saved me hours of headache :)
@timothytimm7040
@timothytimm7040 Жыл бұрын
this is awesome thanks for the video it helped me a lot👌
@prateekchourasia8031
@prateekchourasia8031 4 жыл бұрын
Thanks man! Thanks a lot! I was shit scared because I was going to undo the commit for a month work xD
@SamScott_jr
@SamScott_jr Жыл бұрын
Thank you
@andrewmriv
@andrewmriv 5 жыл бұрын
Thank you for this! Worked like a charm
@TasniMarwane
@TasniMarwane 3 жыл бұрын
Thank you, sir, thank you very much.
@avimehenwal
@avimehenwal 5 жыл бұрын
I am using rebase a lot lately ... thankyou *Y(
@diwakardayal954
@diwakardayal954 Жыл бұрын
Wow 8 year ago xD how are u doing nice video btw
@sergelachapelle7992
@sergelachapelle7992 4 жыл бұрын
Thank you! This helped me a lot...
@AyrtonPeralta
@AyrtonPeralta 3 жыл бұрын
really useful, thanks!
@fatememirjalili
@fatememirjalili 2 жыл бұрын
Thank you so much!
@cyorbea
@cyorbea 4 жыл бұрын
You rule man!!
@TarasAnichyn
@TarasAnichyn Жыл бұрын
Thanks)
@LignariusDM
@LignariusDM 4 жыл бұрын
Hi, thanks for your video, however I keep running into the same issue which is driving me insane. Happens whether I use terminal in VS Code or the Terminal app. I enter git rebase -i HEAD~2 which opens the screen you see at 01:23. Then the weirdness happens. It won't let me replace pick with reword instantly. At first I'll start typing out reword but nothing happens, then after a couple of seconds it finally lets me do it. I'm assuming you're hitting the ENTER key to go to the next screen right? If I hit ENTER all it does is add a backspace. I basically cannot move past this screen, all I can do is Ctrl + C and then :qa! to get out of it. Any help would be much appreciated. Thanks in advance!
@phette23
@phette23 4 жыл бұрын
It sounds like you're entering the vim editor which, unfortunately, does not have very intuitive controls. The reason why you start editing after some time is probably because you type the letter "i" eventually which puts you into "Insert" mode and lets you edit. A short summary is to type "i", make your changes, then use ESC to exit Insert mode, then type ":wq" when you want to Write your changes and Quit. You can see me do these steps in the video. I would recommend either learning how to use vim or changing your Terminal's EDITOR environment variable to nano (`export EDITOR=nano` in your bash profile) which is easier to use.
@LignariusDM
@LignariusDM 4 жыл бұрын
@@phette23 Thanks for the reply, I'll give this a try!
@mazharabbas871
@mazharabbas871 5 жыл бұрын
Thanks, this is really helpful. +1
@sarveshchavan4391
@sarveshchavan4391 7 жыл бұрын
no changes i can see it is as it is on website how long it takes to apply changes!!
@prashansagupta1596
@prashansagupta1596 4 жыл бұрын
After writing reword infront of the commits, I am unable to get to the last like where we write :wq. I tried clicking on the --INSERT-- line still it won't go. What to do?
@phette23
@phette23 4 жыл бұрын
Type a colon ":" then the letters "wq" to Write and Quit. These are the controls for the vim text editor, so if you get lost you can look them up online.
@phette23
@phette23 4 жыл бұрын
Oh it actually needs to be Escape (to exit Insert mode), then colon wq. So altogether it's- ESC : w q
@prashansagupta1596
@prashansagupta1596 4 жыл бұрын
@@phette23 thank you so much. This helped me a lot :)
@AG-im3dz
@AG-im3dz 3 жыл бұрын
Hi Eric, so the second editor appears automatically right after you :wq the first editor? Thanks,
@phette23
@phette23 3 жыл бұрын
Yes! It does. The first editor lets you choose what you're doing and the second one will appear if you need to edit any previous commit messages, e.g. if you choose "reword" or if you "squash" together a few commits.
@AG-im3dz
@AG-im3dz 3 жыл бұрын
@@phette23 thanks !
@sulaimansayyed9248
@sulaimansayyed9248 5 жыл бұрын
Thanks
@nyjeltodd1654
@nyjeltodd1654 7 жыл бұрын
hasn't changed for me
@hyfydistro
@hyfydistro 3 жыл бұрын
What if it's like 50 commits long ago?
@jonathanharris2326
@jonathanharris2326 2 жыл бұрын
What would you do on the final screen if you were rewording multiple commits? Do you go to a new line and type the message?
@phette23
@phette23 2 жыл бұрын
I believe your editor opens once for each commit message you are creating or rewording. So if you rebase and reword two commits, after saving the interactive rebase step, it'll show you two more editors and you have to write/quit from each. Git supports newlines in a commit messages so putting one in a message doesn't cause any special behavior. Only the first line is visible in some contexts, like `git log --oneline`, but the rest are always there and are visible in a simple `git log` with no extra flags.
@mansishah6729
@mansishah6729 7 жыл бұрын
Nice tutorial, thanks. But how can we push updated commit message to remote branch ?
@swatina549
@swatina549 7 жыл бұрын
This process will automatically update changes on your remote branch. Make sure to press Esc button after modifying "pick" to reword and then type ":wq". This will bring you to the new interface window where you can modify your commit message.
@mansishah6729
@mansishah6729 7 жыл бұрын
Yes I did it. Thanks. As 'rebase' rewrites history on Git, after implementing it, I am facing challenge for one of my previous commit. Though I am not changing those files in newer commit, it shows as difference while I am merging two remote branches. Please let me know if you have any idea about it.
@kingslayer5403
@kingslayer5403 Жыл бұрын
I used the ammend command but it did not reflect in the BitBucket.
@phette23
@phette23 Жыл бұрын
Did you push your changes? All git commands only run against your local repo until a push/pull. If BitBucket already has the commit message you want to change, then you need to `git push --force` because you are overwriting data on the remote repo (this is generally dangerous, if you are working with others I would warn them that you are going to force push)
@millieandcupcake
@millieandcupcake 3 жыл бұрын
Hi how do i rewrite 3 commits when i posted them to github already? all 3 say first commit i want to change them. :)
@AverageGuy513
@AverageGuy513 2 жыл бұрын
How do this changed log msg gets pushed to the server ?
@phette23
@phette23 2 жыл бұрын
Run `git push` like you would normally push changes to a remote repo. If the message you want to change is already on your remote repo, you need to `git push -f` but be careful overwriting commits if others are working on the repo too
@flueepwrien6587
@flueepwrien6587 2 жыл бұрын
why does it create a new commit when i try this :(
@phette23
@phette23 2 жыл бұрын
Try what part? `git commit --amend` or `git rebase`?
@Blackjac
@Blackjac Жыл бұрын
@@phette23 For some reason it does the same for me. whenver i try to rename a past commit it makes a new commit of the one im trying to reword.
@phette23
@phette23 Жыл бұрын
@@Blackjac what are the exact steps you're taking? Like `git rebase HEAD~4` and choosing reword? That should reword the given commit message. It will create a _new_ commit to do so, though it doesn't necessarily look like it in the tree (the hash id will change though), but the old one shouldn't stick around. You may have some config setting on that changes the rebase behavior.
@Blackjac
@Blackjac Жыл бұрын
@@phette23 ahhh i see, so I'd have to drop the old commits if i want to delete a commit that contains i.e (typos etc)
@phette23
@phette23 Жыл бұрын
@@Blackjac every commit's ID / hash is based on the state of the repo at that time, including commit messages. So essentially all your commits from the revision up to HEAD are rewritten but the code changes remain the same if you're only rewriting a commit message
@felipe.drumond
@felipe.drumond 6 жыл бұрын
+1
@jaydraws2019
@jaydraws2019 4 жыл бұрын
Thank you so much.
@shrikantamazumder3268
@shrikantamazumder3268 5 жыл бұрын
Thank you
Change a Git Commit in the Past with Amend and Rebase Interactive
18:05
She's very CREATIVE💡💦 #camping #survival #bushcraft #outdoors #lifehack
00:26
Kluster Duo #настольныеигры #boardgames #игры #games #настолки #настольные_игры
00:47
Двое играют | Наташа и Вова
Рет қаралды 2,2 МЛН
git rebase - Why, When & How to fix conflicts
9:45
Philomatics
Рет қаралды 51 М.
How to finally Git Good
9:43
Code Persist
Рет қаралды 39 М.
Learn Git Rebase in 6 minutes // explained with live animations!
6:43
The Modern Coder
Рет қаралды 799 М.
Learn Git Squash in 3 minutes // explained with live animations!
3:56
The Modern Coder
Рет қаралды 303 М.
How to write BETTER git commit messages?
14:19
Ernest Marcinko
Рет қаралды 146
Git: Commit messages with subject and body in the command line
10:01
Vagelis Prokopiou
Рет қаралды 13 М.
Git Commit Message - You Are Not Doing It Correctly
7:57
Monsterlessons Academy
Рет қаралды 34 М.
Git rebase: how to resolve conflicts
7:32
Team Programmer
Рет қаралды 42 М.
Git: change an older commit with rebase interactive
8:48
Dave M.
Рет қаралды 10 М.
She's very CREATIVE💡💦 #camping #survival #bushcraft #outdoors #lifehack
00:26