Llopis Llopis - 1 year ago 68
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 Source

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
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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download