faravish
faravish

Reputation: 43

git remote push makes no effect

I have a shared server(hostgator) which provides me a git client. I want to update codes on my laptop and send them directly to my shared server. My problem is that git gives me no error message, but it does not change anything.

here is what I did:

On server:

[email protected] [~]# git init --bare mycode.git
Initialized empty Git repository in /serverhome/serveruser/mycode.git/

On local computer:

localuser@localpc:~/path/to/local/code$ git init
Initialized empty Git repository in /home/localuser/path/to/local/code/.git/

localuser@localpc:~/path/to/local/code$ git remote add server [email protected]:/serverhome/serveruser/mycode.git

localuser@localpc:~/path/to/local/code$ echo '123456'>test;

localuser@localpc:~/path/to/local/code$ git add test

localuser@localpc:~/path/to/local/code$ git commit -m 'initial commit'
[master (root-commit) 5b7ce12] initial commit
 1 file changed, 1 insertion(+)
 create mode 100644 test

localuser@localpc:~/path/to/local/code$ git push server master
Counting objects: 3, done.
Writing objects: 100% (3/3), 209 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To [email protected]:/serverhome/serveruser/mycode.git
 * [new branch]      master -> master

Where should I see the test file? it is nowhere! neither in /serverhome/serveruser/ nor in /serverhome/serveruser/mycode.git

If I push again I will see this message:

Everything up-to-date

What to do?

Upvotes: 1

Views: 179

Answers (2)

janos
janos

Reputation: 124646

[email protected] [~]# git init --bare mycode.git
Initialized empty Git repository in /serverhome/serveruser/mycode.git/

This is a bare repository. You can use it as a remote and push to it, like you did, but it's not meant for working in it and browsing files.

You can clone from your bare repository on the server and use that clone to see the files in it, for example:

git clone mycode.git mycode

Keep in mind that after you push from your local pc, you will have to do git pull in your clone so it gets the changes from mycode.git. The bare repo will be a common remote for both your local repo and the clone.

If you want to automatically update the clone on the server every time you pushed to it, you can create a post-receive hook. I wrote an article on that on my blog.

Upvotes: 1

Mohammad AbuShady
Mohammad AbuShady

Reputation: 42799

The file is actually pushed, but you are looking for it in the wrong way, you can clone the git folder on the server then checkout master

Upvotes: 0

Related Questions