1

Is it possible to build the git-committed work-space?

I'd like to be able to know if the commits I've done are generating any building error before I will push them to master, but without taking into consideration my currently unstaged changes. (eg. know if partial commit generates errors.)

swiftBoy
  • 35,607
  • 26
  • 136
  • 135

2 Answers2

0

With git 2.5, you can have multiple working trees.

Simply checkout the commit you want to a different folder, and try your build here (or have an Eclipse session with that special working tree as an Eclipse workspace)

If the build passes, then you know you can push.


The other approach would be to use git stash in order to get a clean working tree, build, and then restore the work in progress with a git stash pop.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Doing the checkout to different folder or having a eclipse session open just makes it more confusing and increases the space for errors. I think I will try to make as you and @domyos proposed, stash and build but all into a script. Will also investigate the multiple working trees, but for that I need deeper understanding of git – Rasael Bervini-Monkow Jun 24 '16 at 07:42
  • @RasaelBervini-Monkow I didn't experience any "increase of errors": I have two folders for two different usages. – VonC Jun 24 '16 at 08:00
0

As you can look up in the git docs you can stash all unstaged files with git stash -k. To also stash untracked files use the -u switch. This way you can build your project with just the committed or added files. To revert this run git stash pop. This will restore your unstaged files.

domyos
  • 153
  • 1
  • 9
  • therefore I can create a sh to do the git stash -k -u, javac in the folder and the stash pop and check the shell output to see if has produced any errors, right? – Rasael Bervini-Monkow Jun 24 '16 at 07:39
  • As long as your script file is not in the same directory as your repo this should be working. If the file were in the same directory it would be stashed too. – domyos Jun 24 '16 at 07:48