Edison
Edison

Reputation: 4281

Editing Old Commit in git

I want to redesign my Graphical User Interface in Visual Studio C#.I am using git bash for this purposes since I have a commit log of all my work. I entered the following command

git rebase -i HEAD~3

Then my notepad++ edit popped up since I configured that.Now I type edit before the commit message where I would do my redesigning of form after that git showed me two commands

git commit --amend
git rebase --continue

I entered git commit --amend and it again opened up my notepad++ form then I opened my visual studio form and redesigned the form after that I closd both my visual studio and notepad++ and typed git rebase --continue but it did not worked.

So my question is that in what point of time I should make changing in my Visual Studio Form?

Upvotes: 2

Views: 297

Answers (2)

poke
poke

Reputation: 387507

When the rebasing pauses, you should do your changes. Then you add those changes like you usually do for a commit (using git add). But instead of committing them as a new commit, you amend the previous one using git commit --amend. This will change the commit you are currently editing.

After that, use git rebase --continue to continue rebasing and applying the later commits.

Upvotes: 2

Chris Maes
Chris Maes

Reputation: 37712

you should do your changes BEFORE the

git commit --amend

because "amend" means: take the changed and "amend" them to the last commit. Since you are in the process of rebasing; these changes will thus be applied on the commit where you are at that moment.

in summary:

  1. git rebase -i HEAD~3 (and choose "edit" to edit the commit you want)
  2. Do your changes in visual studio or wherever you want
  3. git commit --amend
  4. git rebase --continue

Upvotes: 1

Related Questions