0

I'm making large changes to an R project on a different git branch which includes changes to packrat packages and versions. When I switch back to the original master branch after making those changes, I need to run packrat::restore() to get back to the original project state because I am only tracking the packrat.lock file. Then, if I switch back to the development branch I have to run packrat::restore() again to pick up where I left off with the new changes.

Do I have this correct? Can you suggest a better workflow that eliminates the need to run packrat::restore() which can take a lot of time?

This also makes it difficult to schedule jobs to run automatically from the master branch. I have to make sure to switch to the master branch and run packrat::restore() before scripts are scheduled to run, and I can't work on the development branch while the background jobs are running.

Giovanni Colitti
  • 1,982
  • 11
  • 24
  • I don't understand. What did I get wrong? And you say no to the second question which was asking for a better workflow but then you suggest `git worktree` as a possible better workflow? – Giovanni Colitti Dec 02 '19 at 17:14
  • How can you work on two different branches simultaneously if the two branches require different `packrat` package libraries? Is this possible if I only track the `packrat.lock` file? I don't doubt you are correct. I just don't understand it yet. Thanks for your comment! – Giovanni Colitti Dec 02 '19 at 17:17
  • 1
    I think: yes (you have it correct) and no (no better workflow that I'm aware of). If you switch git branches frequently, you might consider [`git worktree`](https://blog.developer.atlassian.com/git-2-7-release/). While it does not reduce the need for repeated `packrat::restore()`, it does enable looking at and/or working in two branches of the same repo simultaneously. Just a side-comment.) (This comment is a correction/reduction of previous comments, since deleted.) – r2evans Dec 02 '19 at 17:22
  • 1
    I will look into `git worktree`. Thanks for the suggestion. – Giovanni Colitti Dec 02 '19 at 17:22

0 Answers0