However bash I modify a circumstantial perpetrate?

However bash I modify a circumstantial perpetrate?

I person the pursuing perpetrate past:

  1. HEAD
  2. HEAD~
  3. HEAD~2
  4. HEAD~3

git commit --amend modifies the actual HEAD perpetrate. However however bash I modify HEAD~3?


Usage git rebase. For illustration, to modify perpetrate bbc643cd, tally:

git rebase --interactive bbc643cd~

Delight line the tilde ~ astatine the extremity of the bid, due to the fact that you demand to reapply commits connected apical of the former perpetrate of bbc643cd (i.e. bbc643cd~).

Successful the default application, modify pick to edit successful the formation mentioning bbc643cd.

Prevention the record and exit. git volition construe and mechanically execute the instructions successful the record. You volition discovery your self successful the former occupation successful which you conscionable had created perpetrate bbc643cd.

Astatine this component, bbc643cd is your past perpetrate and you tin easy amend it. Brand your modifications and past perpetrate them with the bid:

git commit --all --amend --no-edit

Last that, instrument backmost to the former Caput perpetrate utilizing:

git rebase --continue

Informing: Line that this volition alteration the SHA-1 of that perpetrate arsenic fine arsenic each youngsters -- successful another phrases, this rewrites the past from that component guardant. You tin interruption repos doing this if you propulsion utilizing the bid git push --force.


Usage the superior interactive rebase:

git rebase -i # Show your commits in a text editor

Discovery the perpetrate you privation, alteration pick to e (edit), and prevention and adjacent the record. Git volition rewind to that perpetrate, permitting you to both:

  • usage git commit --amend to brand modifications, oregon
  • usage git reset @~ to discard the past perpetrate, however not the modifications to the information (i.e. return you to the component you have been astatine once you'd edited the information, however hadn't dedicated but).

The second is utile for doing much analyzable material similar splitting into aggregate commits.

Past, tally git rebase --continue, and Git volition replay the consequent modifications connected apical of your modified perpetrate. You whitethorn beryllium requested to hole any merge conflicts.

Line: @ is shorthand for HEAD, and ~ is the perpetrate earlier the specified perpetrate.

Publication much astir rewriting past successful the Git docs.


Don't beryllium acrophobic to rebase

ProTip™: Don't beryllium acrophobic to experimentation with "unsafe" instructions that rewrite past* — Git doesn't delete your commits for Ninety days by default; you tin discovery them successful the reflog:

$ git reset @~3 # go back 3 commits$ git reflogc4f708b HEAD@{0}: reset: moving to @~32c52489 HEAD@{1}: commit: more changes4a5246d HEAD@{2}: commit: make important changese8571e4 HEAD@{3}: commit: make some changes... earlier commits ...$ git reset 2c52489... and you're back where you started

* Ticker retired for choices similar --hard and --force although — they tin discard information.
* Besides, don't rewrite past connected immoderate branches you're collaborating connected.



Connected galore methods, git rebase -i volition unfastened ahead Vim by default. Vim doesn't activity similar about contemporary matter editors, truthful return a expression astatine however to rebase utilizing Vim. If you'd instead usage a antithetic application, alteration it with git config --global core.editor your-favorite-text-editor.


Mistake producing weblog contented

The Desert Moon Mystery 🌕🔍 | A Thrilling Tale of Secrets in the Sands

The Desert Moon Mystery 🌕🔍 | A Thrilling Tale of Secrets in the Sands from Youtube.com

Previous Post Next Post

Formulario de contacto