Let's say I'm merging a pull request and want also to accompany the merge with a line in the changelog:
> git merge --no-ff otherguy/feature-x
> echo "Feature: X" >> changelog
> git commit -am "Changelog update"
> git push
A similar thing is possible in a single commit:
> git merge --no-ff --no-commit otherguy/feature-x
> echo "Feature: X" >> changelog
> git commit -am "Merge otherguy/feature-x + changelog"
> git push
So that the same commit will contain both the merge and the file changes.
Granting that I always update the changelog when merging from the downstream repositories, here is a question:
Is the latter way a sane thing to do and what unexpected consequences might show up later?
Update: As for why I need a separate file changelog when I already have a git log, the one in the file is more pruned (entry or so per merge, not per commit), sometimes better worded and in a certain format (e.g. debian/changelog). So, it's for external usage.
Updated answer for 2020:You can then edit the merge commit as desired via git commit --amend . Find the merge commit you want to edit in the todo list. Insert a new line after the merge commit that contains only break (or b ). Use git commit --amend to edit the merge commit as desired.
If the commit only exists in your local repository and has not been pushed to GitHub.com, you can amend the commit message with the git commit --amend command. On the command line, navigate to the repository that contains the commit you want to amend. Type git commit --amend and press Enter.
Usually git does not overwrite anything during merge.
Yes you can being on a new branch doesn't stop you from using a commit.
You should first consider if it really is useful to keep a changelog committed in the repository, when you have git there to keep the changelog in the first place.
Also, adding things in merge that didn't exist in either branch is called an evil merge, and is not a good practise anyway.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With