splunge
splunge

Reputation: 73

Git Not Responding to Branch Changes

I have two Git branches, A and B. I am using Git to deploy changes from server 1 to server 2.

Branch A has a set number of files. Branch B has an extra directory (foo) with more files and a change to one of the files (bar) outside of the extra directory. I have branch A locally and a remote branch origin/A. The same for branch B and branch origin/B.

On server 1 if I check out branch A I see the original content in bar and I do not see the extra directory, foo. If I checkout branch B bar changes and the extra directory, foo appears.

Great. Server 1 works.

The problem is on server 2. If I checkout branch A bar changes but the extra directory, bar does not disappear as it does on server 1. On server 2 if I change to branch B bar also changes and the extra directory, foo is still present. So in summation, when I deploy to server 2 via git only changes within a file occur and addition/removal of files does not occur.

Is this normal behavior for git or should the files disappear when I checkout branch A?

Thanks

Upvotes: 1

Views: 220

Answers (1)

CodeWizard
CodeWizard

Reputation: 142074

The problem is on server 2. If I checkout branch A bar changes but the extra directory, bar do not disappear as it does on server 1

This is exactly how git behave, once you checkout branch the content of the working directory is updated with the content of the give branch.

This is the whole point behind branches. You can work on different content.

How else do you accept it to be? Every time you checkout different branch that it would checkout all the files in the whole repository?

Its only checking out the content of the given branch and updating the working directory.

Upvotes: 1

Related Questions