13

I currently have a UAT branch and a master branch. I merge the UAT branch into Master on a weekly basis (after a weekly release).

I have foolishly checked in another item onto UAT before doing the merge.

Can I do something like this:

git merge uat 4d9ed3b8122a215f64f07028c92bb0cb0a8b4570

So would that merge UAT up to that commit?

Andrew Berry
  • 853
  • 3
  • 10
  • 25
  • 2
    Possible duplicate of [Merge up to a specific commit](https://stackoverflow.com/questions/8223103/merge-up-to-a-specific-commit) – ElasticCode Jul 29 '19 at 08:38

1 Answers1

22

A git branch is merely a pointer to a commit. Therefore, you can definitely ignore the fact that the commit you want is somewhere behind the uat branch, and just do this (from master):

git merge 4d9ed3b8122a215f64f07028c92bb0cb0a8b4570

This will create a merge commit between the current tip of master (which is just another pretty name for a long commit hash), and 4d9ed3b8122a215f64f07028c92bb0cb0a8b4570.

Madara's Ghost
  • 172,118
  • 50
  • 264
  • 308
  • Ok thanks for that. What if there is a third brach, would it pick up the commits in the third branch as well, or will it work out just to merge the UAT changes? http://i.imgur.com/ElRb4Wj.png I have linked an image below. I want to merge UAT to #24837 but not include the changes in the pw-hash branch. – Andrew Berry Sep 17 '15 at 09:12
  • Did you mean merging UAT into master, or merge UAT to its direct parent #24837 (with no ff)? Though both case would be possible: checkout to master then merge with UAT; checkout to #24837 then merge with UAT by `git merge UAT --no-ff` – orb Sep 17 '15 at 09:32