Skip to content

Instantly share code, notes, and snippets.

@dylan-k
Forked from vasi/gist:6695286
Last active December 24, 2015 08:29
Show Gist options
  • Save dylan-k/6770909 to your computer and use it in GitHub Desktop.
Save dylan-k/6770909 to your computer and use it in GitHub Desktop.
This is one way to work with a subset of files, within a Git Branch. See also: http://ask.metafilter.com/249100/Can-a-Git-Branch-Contain-Only-a-Sub-Set-of-the-Repository#3617407
# (on master)
git checkout -b subset
git rm file1.txt file2.txt # (remove the files you don't want on this branch)
git commit -m 'removed some stuff'
git checkout master # (go back to master)
git merge --strategy ours subset # (record a merge from the subset branch, but make no actual changes to master)
git checkout subset
# (edit file3.txt)
git add file3.txt
git commit -m 'edited file3'
git checkout master # (back to master again)
git merge subset # (will merge the change to file3.txt but still not the deletions)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment