0

I've created branchA from the dev branch and it contains some configuration files that I've skip worktree'd . I have made additional changes to non-skip-worktreed files. I'd like to merge these changes back into dev, but not merge the skip-worktreed files. What is the best way to do this?

In summary this is what I want to do :

  1. merge my changes into dev ( but not the configuration files)
  2. delete the old branchA
  3. create a new branchB that contains the updated dev branch along with my old configuration files from branchA
Community
  • 1
  • 1
AndrewD
  • 4,924
  • 3
  • 30
  • 32

1 Answers1

1

I think sparse checkout might do for this, it maintains the index and worktree so selected files aren't checked out and automatically marks them skip-worktree.

$ cat >.git/info/sparse-checkout <<\EOD
*
!/configs/*
EOD
$ git config core.sparsecheckout true
$ git checkout

The warnings in the sparse checkout docs matter, with sparse checkout on, checkout updates the index and worktree to match the desired state -- so any files that shouldn't have been checked out and whose index entries aren't already marked as skipped get deleted (and their index entries marked, git no longer cares what you put there). You've already got your configs marked skipped so that shouldn't be a problem, just be mindful of what's going on.

I'd say try a testflight on this in a scratch repo for sure

git clone -s . /tmp/deleteme

I haven't really used sparse checkout for anything beyond smoketests myself.

jthill
  • 55,082
  • 5
  • 77
  • 137
  • this worked really well for me. thank you! The only thing that bothers me is that I have to remember to configure sparse-checkout after I create the repo and after I add my skip-worktree files. – AndrewD Feb 27 '15 at 21:23