Reputation: 67
I have a local repo on my laptop and a remote repo on a server.
On laptop:
$ git pull ssh://xxxx@xxxxxxx/home/gittest/ master
$ cat a.php
<?php
echo 'hello';
?>
so I changed file on laptop
$ vim a.php
$ cat a.php
<?php
echo 'hello';
echo 'hello2';
?>
and commit it
$ git add a.php
$ git commit -m 'update'
$ git push ssh://xxxx@xxxxxxxx/home/gittest/ master
Now I check the file on server
$ cat a.php
<?php
echo 'hello';
?>
There's still old version
$ git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: a.php
#
How to make files update on server?
Upvotes: 2
Views: 284
Reputation: 15109
In Git there's
When you run git push
, you only update the repository on the remote server. If remote is not a bare repository, it also has a working tree. But it has to be changed by a separate actiion.
Run git remote show <remote name>
to see branch status
Are you using git for deployment to a server? If so, you need to either:
git checkout master
to bring the working tree in accordance with the repoIf you don't use git for deployment, why need any files on the remote? In such case it's best to use a bare repository.
Upvotes: 4
Reputation: 14685
You appear to be pulling from and pushing to a working repository.
This won't work the way you want it to, because pushing updates the respository, but not the working copy.
After the push, the version in your server working copy appears modified, because it is different to the HEAD version in the repository that was updated by the push.
You need a bare repository to share from. You can read about that here among other places.
Upvotes: 4