0

I need 20 branches, each branched from a single main feature branch. These branches will be used to generate pull requests (BitBucket) repeatedly as work progresses. So every now and again, I want to checkout a PR branch, then checkout again from the feature branch only those files that were originally checked out from the feature branch without having to remember which files those were.

Currently, I maintain a script that keeps track of which files to associate to which PR branch and when the PR branch name is passed, it checks out the files, adds, commits, then pushes. What is an easier way to "refresh" the PR branches?

quickdraw
  • 101
  • 8
  • I don't think there's anything easier than what you're doing. Git isn't about *files*, or even about *branches:* it's all about *commits*. A branch name is just a way to find some particular commit, and every commit has a full snapshot of every file. So every branch-tip commit has every file (that it has): there's no such thing as "the files checked out from another branch", there are only "the files in this commit". You can diff any pair of commits to see what's different in the files in those two commits, but that doesn't seem likely to help with your goal here. – torek Nov 12 '21 at 13:44
  • @torek Thanks for your time. That was my understanding. I was just hoping there would be some list stored somewhere of the file checkouts and some option on some git comment for iterating on that list. – quickdraw Nov 13 '21 at 16:15
  • The index (`git ls-files` will dump the index contents) shows what Git has proposed for the *next* commit, and after an initial `git checkout` or `git switch`, that's a match to whatever you checked out / switched-to. But that's all Git has here. – torek Nov 13 '21 at 19:23
  • Oh, that's a really good call, Thanks @torek. I can use that to create my script and then manually add to the script as I check out new files from the wip branch. – quickdraw Nov 14 '21 at 23:01

0 Answers0