I'd like to ask a question regarding Github, specifically pull requests.
Let's say for example that there is an open pull request.
I made a commit 'feat: add feature', and then a little while later someone else made a couple more commits to the pull request, 'feat: add feature b' and 'feat: add feature c', if I wanted to rename my original commit, is there a way to do that?
If I simply did something like git reset HEAD~
, would that ruin the two commits made after mine?
Thanks!
You can achieve your renaming of the first commit by interactive rebasing
.
if there are 3 commits on the head use this command git rebase -i HEAD~3
This will open up something like this
pick a1beca Your commit
pick a2beca feat: add feature b
pick a3beca feat: add feature c
...
Hit "i" on the keyboard to activate interactive mode. Go with reword for your commit
reword a1beca Your commit
pick a2beca feat: add feature b
pick a3beca feat: add feature c
...
Hit "esc" to exit interactive mode. And then :wq
This will then ask you to type your desired commit message.
For more information read here . Some practice will take you there.
You can change your commit by run this code:
git reset --soft HEAD~1
If you want to undo both commit and changes: ⚠️ Be sure that you want to lose the changes:
git reset --hard HEAD~1
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.