Reputation: 8678
I setup a git repo on school machine and then clone the same repo on another home machine. I have commited and pushed on the home machine now I want to update the change to the school machine. What should I do? I tried git remote update
but it didn't update when I checked the files.
Upvotes: 0
Views: 1960
Reputation: 463
Just execute this command in your school machine:
git pull origin master
Hope it helps.
Upvotes: 1
Reputation: 5480
Since you tagged the question with bitbucket
, I'm going to make the following assumptions. If any of these assumptions are not correct, clarify in your question and I will update this answer.
bitbucket
bitbucket
repository on the school machinebitbucket
repository on your home system.git add <changes>
git commit -m '<message>'
git push <remote> <branch>
git remote update
The git remote update
fetched the changes in all remotes, so if the changes pushed by the home repository are on the same remote they have been loaded into the repository on the school system.
The key here is the repository is the .git
folder, so the refs in it were updated -- but the working copy was not. In order to update the working copy you will need to merge the changes fetched to the local repository with the working directory. This is done with a git merge <options>
.
If my assumptions, based on your tags, is not correct and there are only the two repositories; school and home. Then you need to git merge <options>
to bring the changes into your working copy, unless you have local changes as well; in which case do something similar to the following if
git stash
git merge <options>
git stash pop
At this point resolve any conflicts between the local changes popped from the stash and commit.
If you don't want to keep the changes in your local copy, you can return the working copy to the state of the last commit with a git reset --hard
.
One final word of caution, don't push into a non-bare repository if you can avoid it -- and you generally can. It is much better for the school repository to pull (fetch/merge) the changes from the home repository than it is for the home repository to push to the school repository.
Upvotes: 0
Reputation: 67
you did it wrong :)
if you are using repository not as a bare repository on a school machine you need to
git reset --hard
after pushing to it, because you just update ref's not a working copy
much more better is using bare repository and pull/push to it from other machine/repository Git on server
Upvotes: 1