For a web site, I have master and staging, I have worked on staging for about 10 days. How do I tell for sure what has changed since my last merge, or when that merge was? Most of the merges I have done end up being FFs so I can't log them like git merge branch -m 'merging staging'
(git reports it ignored -m). I usually merge master into staging for testing before merging staging into master for more testing and deployment.
I could tag each one but I'm worried about the clutter of doing that for merges. What I'd like to know is "roughly, what changed since my last merge of staging into master?" Then I could make sure I spent extra time investigating those changes in the final examination. Sometimes co-workers make changes I hadn't noticed until this stage.
I suppose since staging->into->master merges are rare, I could tag them and then do a "git whatchanged tag" but I'm hoping there is a non-tag way to do it. Thanks.
Try simply git whatchanged master.. staging to see what changed on staging since you last merged from staging to master.
Merging. When you run git merge , your HEAD branch will generate a new commit, preserving the ancestry of each commit history.
To see the merge commit's message and other details, use git show-merge with the same arguments.
You can use the Git reset command to undo a merge. Firstly, you need to check for the commit hash (or id) so you can use it to go back to the previous commit. To check for the hash, run git log or git reflog . git reflog is a better option because things are more readable with it.
git log has a tool you can use to visualize all of this merging, --graph. The output looks like this: This graph shows not only the commits (as asterisks *) but also their “parent” commits. Most commits—“ordinary” commits — have only one parent: the last commit of the branch you were on when the commit was created.
A git merge operation is performed by running the command “git merge <name of the branch to be merged (in our case it is “dev”)>”. When we perform merging, git always merges with the current branch from where we are performing the operation (in our case it is “main”). By this, the branch being merged is not affected.
For instance, if you wanted to find the last commit that added or removed a reference to a specific function, you could call: The last really useful option to pass to git log as a filter is a path. If you specify a directory or file name, you can limit the log output to commits that introduced a change to those files.
When you get the hash of the commit you want to get back to, run git reset --hard commit-before-the-merge: You should see some things get removed from your code editor when you run the command. If you are not sure of the hash of the last commit, you can run git reset --hard HEAD~1 to go back to the commit before the merge:
git log --merges -n 1
works well. From man git-log
:
--merges Print only merge commits. This is exactly the same as --min-parents=2.
Here's an example using --pretty=format:"%H"
to get just the SHA.
$ git log --pretty=format:"%H" --merges -n 1 f32e1f13eef7d5843e8063b8709d01af6dcd5dbf
Credit goes to Jefromi for their comment on another answer.
Try this, it will select the last branch where the commit message starts with "Merge":
git show :/^Merge
Here's a website with a few git tips that might help you out.
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