0

I have set up a repo at a server of mine like this:

> git init 
> git config --local receive.denyCurrentBranch updateInstead
> git add *
> git commit -m "Init Git" 

This is how I have pulled the repo, made some changes and pushed it back to the server:

> git clone ssh://user:password@host.com/backend
> git add *
> git commit -m "First Push"
> git push origin master

That all goes through without any problems!

If I now check the branches and logs I get on my server as well on my computer this:

> git log
commit 8f69afeffae2c44d6952dbb753a003deea2fbe2a
Author: Mac 
Date:   Thu Jun 21 17:47:19 2018 +0200

    First Push

commit 787c90ee79a4f3da207a57fcca552ebb7087294c
Author: Server 
Date:   Thu Jun 21 17:43:46 2018 +0200

    Init Git

> git branch -v
> * master 8f69afe First Push

That means both my computer as well as the server are up to date and should contain the same files. However, this is not true...

I have edited a file on my computer before I have committed it and pushed it back to the server with the message "First Push". The changes are made on my computer but I don't see the changes on my server.. How can that be if the server has received the push and says that he is on the same branch?

Do I have to checkout? How can I update the repo on the server as well?

If I pull the repo again to my computer, it says "All files are up to date"!

Kind regards and Thank You!

Jan
  • 1,180
  • 3
  • 23
  • 60
  • 1
    How do you inspect the changes on the server? Servers usually run the `--bare` repository with no working copy. – choroba Jun 21 '18 at 16:15
  • Via FTP and also I can see that the website hasn't changed... – Jan Jun 21 '18 at 16:24
  • I just have tried to do this but now after I have inited the repo and want to add files, I get "fatal: This operation must be run in a work tree" – Jan Jun 21 '18 at 16:30
  • I have changed the git repo on my server to a git bare repo. Still the same problem.. Hasn't changed anything... I still can see that the repo on the server is on the newest commit, but the changes are not made.. – Jan Jun 21 '18 at 16:38
  • How do you check the changes in a bare repo? – choroba Jun 21 '18 at 18:35
  • As I said: Via FTP and they should also take effect on the website... – Jan Jun 21 '18 at 18:40
  • Can you show how you check via FTP? What code generates the website? – choroba Jun 21 '18 at 19:13
  • I just edit the index.php from `echo "Hello World";` to `echo "Good Morning";` and nothing changes.. not on the website as well as in the file via FTP – Jan Jun 21 '18 at 20:10
  • Oh, so you're using git for deployment! It's a different kind of server. You shouldn't push to it, you should pull from a git server there instead. – choroba Jun 21 '18 at 20:27
  • @Jan Did the answer help you solve the problem? If yes, can you mark the answer. And it will also benefit others who meet similar questions. – Marina Liu Jul 02 '18 at 03:49

1 Answers1

0

How can that be if the server has received the push and says that he is on the same branch?

You puhed the local master branch to remote master branch (same branch in remote).

To push local branch to the branch of git server, it’s specified by the the command git push origin master. The command is equal with git push origin <localbranch>:master. That means you pushed the local master branch to remote master branch.

And to trouble the reason why local master branch version is different from remote master branch version, you can check with below aspects:

1. Check if local branch has un-committed changes

Use the command git status to check if the working tree is clean. If there has uncommitted changes, you should commit and push the changes to remote.

2. Check the difference between local master branch and remote master branch

Use below commands to check the file differences between local master and remote master branch:

git fetch origin
git diff master origin/master

3. Check the diff logs between local master branch and remote master branch

Use below commands to check the diff logs between local master branch and remote master branch:

git log master..origin/master --oneline
git log origin/master..master --oneline
Marina Liu
  • 36,876
  • 5
  • 61
  • 74