tirenweb
tirenweb

Reputation: 31729

git: after changing repo, how to get the new differences?

I changed the repo IP (repo B) in .git/config one week ago.

Today I have changed again the IP to the oldest one (repo A), then I have run git st, I expected that after running git st it shown the differences between my local machine project and the oldest repo A, but it still shows the differences related to the repo B..

Upvotes: 1

Views: 37

Answers (1)

TwentyMiles
TwentyMiles

Reputation: 4089

Git status (which it sounds like you have aliased to git st) does not compare your working copy's state to a remote repository's state. Git, unlike subversion for example, does not look anywhere except it's own local state unless you explicitly ask it to.

I would not recommend switching back and forth between repositories like you are doing, since this is bound to cause headaches because git will see two different histories but think they should be one single history. Instead, add a second remote using

git remote add repoA git://someplace.com/your/repoA

You can then pull in changes using git fetch repoA and you can compare your working copy changes to them using git diff. git status will not show the changes between your local copy and the remote copies unless you first merge in the changes from the remotes to your working copy. For more information on this sort of thing, take a look at the official git documentation here and here.

Upvotes: 1

Related Questions