1

About a week ago I started to play around in a new feature branch of my project. I named that branch "uploadtest" just as a way to find out how stuff works before I really do it.

Turns out, the uploading feature I was trying to implement was so simple that I've decided to simply finish work on that. Once I was done I merged the branch back into my "develop" branch. However, now looking at the commit history is a little weird, because the already merged branch makes it seem like a test, when in reality something like "uploadimpl" would be way clearer.

For my one-man project it's obviously not a problem, but if I were to do this in a team project, well, confusion would go through the roofs. Therefore, are there methods to retroactively rename a (merged) branch?

Selbi
  • 813
  • 7
  • 23

1 Answers1

3

Renaming a branch is trivial, see How do I rename a local Git branch?

However, I think the issue you are referring to is the commit message, not the branch name. Once merged, the actual name of the branch is unimportant. In fact, you can simply delete it. However, the name of the branch is typically included in the merge's commit message. It sounds like you want to edit the history to change the name of the branch on the merge's commit message. This is possible, but re-writing history can be dangerous, especially in a team scenario.

If you have not pushed the merged changes to the remote repository then you can still accomplish this. Check out this question for some options: How to modify existing, unpushed commits?

If you have pushed these changes, then you are in dangerous territory. My general guidance is simply don't do this. Just let it go... But if you must, then check this out: Changing git commit message after push (given that no one pulled from remote)

fabien7474
  • 16,300
  • 22
  • 96
  • 124
Kevin Burdett
  • 2,892
  • 1
  • 12
  • 19
  • I had no idea merged branch names are included in the commit message. The git GUIs visualize them in a way that make it seem like branches are forever uniquely identified in a separate manner. Though, I'm a little dumbfounded at the given solution. From what I could gather, --amend lets you rephrase the most recent commit message, but in my scenario the branch I'd like to rename is already many commits old. – Selbi Aug 30 '16 at 14:30
  • @user3216060 There wasn't any reference to a Git GUI in the question, perhaps if you include the GUI you are using then someone with expertise on that product can offer a better answer. I only use the command line Git, so I won't be able to help there.The link I provided also includes an interactive rebase suggestion, which may be used to rephrase commit messages that are older. The amend option is simpler, so it is typically offered first. – Kevin Burdett Aug 31 '16 at 15:14