Git. Checkout feature branch between merge commits

Posted by mageslayer on Stack Overflow See other posts from Stack Overflow or by mageslayer
Published on 2010-03-14T18:51:46Z Indexed on 2010/03/14 18:55 UTC
Read the original article Hit count: 249

Filed under:
|

Hi all

It's kind weird, but I can't fulfill a pretty common operation with git. Basically what I want is to checkout a feature branch, not using it's head but using SHA id. This SHA points between merges from master branch.

The problem is that all I get is just master branch without a commits from feature branch. Currently I'm trying to fix a regression introduced earlier in master branch.

Just to be more descriptive, I crafted a small bash script to recreate a problem repository:

#!/bin/bash

rm -rf ./.git
git init

echo "test1" > test1.txt
git add test1.txt
git commit -m "test1" -a

git checkout -b patches master

echo "test2" > test2.txt
git add test2.txt
git commit -m "test2" -a

git checkout master

echo "test3" > test3.txt
git add test3.txt
git commit -m "test3" -a

echo "test4" > test4.txt
git add test4.txt
git commit -m "test4" -a

echo "test5" > test5.txt
git add test5.txt
git commit -m "test5" -a

git checkout patches
git merge master    

#Now how to get a branch having all commits from patches + test3.txt + test4.txt - test5.txt ???

Basically all I want is just to checkout branch "patches" with files 1-4, but not including test5.txt.

Doing: git checkout [sha_where_test4.txt_entered]

... just gives a branch with test1,test3,test4, but excluding test2.txt

Thanks.

© Stack Overflow or respective owner

Related posts about git

Related posts about checkout