Llopis Llopis - 2 months ago 12
Git Question

Which branch will be used, when I run code from the terminal?

If I have software under git in several branches which code will be used when I run the code?
Will be used the master, or the one with last committed changes?

Answer

You can test it with:

mkdir test
cd test
vim test.R
  print("hi") # save with ESC, CTRL+x
git add test.R
git commit -m "Adding file"
git branch newbranch # create new branch
git checkout newbranch # switch to the new branch
vim test.R # edit the file on the new branch
  print("bye") # save with ESC, CTRL+x
cd ..
cat test/test.R
print("bye")
R CMD BATCH test.R # Run the program with an external application
cat test.Rout # observe the output
> print("bye")
[1] "bye"

So even if the changes are uncommitted the branch you were working on will be used.