I have already pushed the code without associating with a work item(defect id) raised in git but forgot to associate code changes with a work item in a GIT. how will I edit that push and associate with defect id now?
2 Answers
Assuming this is your last commit, the way I usually do is first take a copy of your local folder in case things goes south.
- Undo last commit.
git reset HEAD~1
- Add a new commit with all changes.
- Push new branch with force overwriting the remote
git push -f
p.s. Depending on git server that you use, you might need additional permission for this.

- 308
- 2
- 4
- 21
git rebase -i "commit hash you want to change
This will open your default editor (usually vi) with a list of commits and actions for each one. By default, the action is pick.
For any commit you wish to change the message, change pick to reword.
Save and quit (in vi: :wq).
For each such commit, you'll get an editor to edit the commit message. Change it as you see fit, save and quit.
Once you're done editing all the commit messages, you'll return to the command prompt, and have a new tree with the updated messages.
You can now upload them to github by using git push origin --force.
If you just need to fix your last commit, you can replace steps 1-4 with git commit --amend.

- 1
- 3