Reputation: 547
Let's say that I have a git repository containing the following branches:
On the QA branch I have commit 'A' which has been approved for release, I also have commit 'B' that has not been approved for release.
Is there a way for me to merge only up to commit 'A' into staging and master so that the changes not approved for release are kept out of the staging/production environments?
Upvotes: 1
Views: 162
Reputation: 164759
On the QA branch I have commit 'A' which has been approved for release, I also have commit 'B' that has not been approved for release. Is there a way for me to merge only up to commit 'A' into staging and master so that the changes not approved for release are kept out of the staging/production environments?
What you're asking for demonstrates a problem with managing releases with branches: you can only have one thing in QA at a time, and they tend to pile up. A lot of complexity can be avoided if you use the feature branch workflow and do QA and staging with tags instead of branches.
Now, to fix it in your current workflow...
You can make a feature branch off B, move QA to A, deal with QA (now at A) normally, and work on B as normal.
Here's your repo, presumably.
Z - A - B [QA]
\
C - D [staging]
\
E - F [master]
$ git branch feature/B B
[feature/B]
Z - A - B [QA]
\
C - D [staging]
\
E - F [master]
$ git checkout QA
$ git reset --hard A
$ git push --force-with-lease
B [feature/B]
/
Z - A [QA]
\
C - D [staging]
\
E - F [master]
Upvotes: 1
Reputation: 534977
The "object" of a git merge
command is always a commit. (The fact that you usually say the name of a branch is merely a contingent fact, because a branch just happens to be another name for a commit.) So, using the SHA for the commit you want to merge "only up to", just merge it.
Upvotes: 1