3

I'm tasked with making our build go faster and one of the movements I'm trying to make is from CVS to Git (wish me luck guys). Currently one of the most cumbersome tasks in our build is the actual checkout of the project which can take around 15 minutes at the worst of times. I will be setting up a CI to build whatever is in a branch and was wondering how I could make the build happen each time without needing to completely checkout the entire project from a clean workspace every time.

The project contains a lot of submodules and from my understanding, submodules can get a bit tricky to deal with when you need to update them or remove them. My experience with submodules is that unless you get the order of operations right, you can get left with rogue files here or there when doing resets and cleans.

Is there some sequence of commands where given a current clean working-tree, I can checkout another commit and call the git clean,reset,submodule-sync,update whatever to result in another clean working-tree? Like i said before I'm trying to work out the path of least downloading/checkouting to get to my new working tree.

Thanks for your help and If all you have is some good references for me to look up all the edge cases myself I would highly appreciate it!

1 Answer 1

2

I usually do the following:

git clean -fd
git reset --hard
git checkout <new branch name>

you may need to add on the end:

git submodule update --init
4
  • what about the submodules, wouldn't you need to call git submodule update? Also, After the submodule update, would i need to call that for each submodule? Commented Jul 11, 2014 at 2:16
  • I think git reset --hard is sufficient
    – 0x90
    Commented Jul 11, 2014 at 2:18
  • I'm doing some tests right now with a made up repo pointing to some submodules because I have a feeling there are some edge cases missing here. but thanks for the start! Commented Jul 11, 2014 at 2:37
  • 1
    I found this question that contained some more insight. See my edit to your answer to see if you agree. (the reason why I added the second recursive is that if the project has already been initialized, then it won't be updated with the first statement. Commented Jul 11, 2014 at 2:47

Not the answer you're looking for? Browse other questions tagged or ask your own question.