-1

I am trying to get my GIT Remote working. On my Windows local machine GIT remote is setup like this:

C:\xampp\htdocs\helloworld\test [master]> git remote
develop
C:\xampp\htdocs\helloworld\test [master]> git remote -v
 develop ssh://root@develop.livm.net:/var/www/html/demo/iMedicWare/nsg/helloworld/test/.git/ (fetch)
 develop ssh://root@develop.livm.net:/var/www/html/demo/iMedicWare/nsg/helloworld/test/.git/ (push)

I have GIT installed on the linux server that where the application will live. What do I have to setup on Windows local machine and/or linux server in order to get code from my local machine changes to be pushed on the linux server?

This is the command I am running on my windows local machine to push changes on the linux server:

C:\xampp\htdocs\helloworld\test [master]> git push develop master
Warning: Permanently added 'develop.livm.net,192.168.19.70' (RSA) to the list of known hosts.
root@develop.livm.net's password:
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 358 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
To ssh://root@develop.livm.net:/var/www/html/demo/iMedicWare/nsg/helloworld/test/.git/
1527464..04f0441  master -> master
C:\xampp\htdocs\helloworld\test [master]>

I do not see the code changes on the linux server master branch after I run this command from my windows local machine. So I am not sure what I am doing wrong?

On my remote machine the project is here:

/var/www/html/demo/iMedicWare/nsg/helloworld/test/

and there is a .git folder in there like this:

/var/www/html/demo/iMedicWare/nsg/helloworld/test/.git

Is the project supposed to be inside .git folder or the way I currently have it setup?

  • Check inside the .git folder on your remote machine. Is the project directory in there? If it is try changing your remote to ```ssh://root@develop.livm.net:/var/www/html/demo/iMedicWare/nsg/helloworld/test/``` – Anas Alkhatib Nov 05 '14 at 18:21
  • On my remote machine the project is here: /var/www/html/demo/iMedicWare/nsg/helloworld/test/ and there is a .git folder in there like this: /var/www/html/demo/iMedicWare/nsg/helloworld/test/.git Is the project supposed to be inside .git folder or the way I currently have it setup? – bioscorpion Nov 05 '14 at 18:56
  • Were you able clone from that URL? or did you add it as remote after cloning? – Anas Alkhatib Nov 05 '14 at 21:43
  • I have used git in the past as a developer. But now I am learning to configure git and that is what I am not understanding. So I am not sure what I did when I first did this setup, cloning from url or remote cloning. What should I do? – bioscorpion Nov 06 '14 at 21:14

2 Answers2

0

When you clone the project from your linux server, use this path:

git clone ssh://root@develop.livm.net:/var/www/html/demo/iMedicWare/nsg/helloworld/test/

to add it as a remote to your current project: try

git remote add new_develop ssh://root@develop.livm.net:/var/www/html/demo/iMedicWare/nsg/helloworld/test/

Anas Alkhatib
  • 1,110
  • 1
  • 9
  • 22
  • When I do this procedure:git add testgit_windows.php git commit -m "testing push to development server" git push develop master root@develop.livm.net's password: Counting objects: 5, done. Delta compression using up to 4 threads. Compressing objects: 100% (3/3), done. Writing objects: 100% (3/3), 357 bytes | 0 bytes/s, done. Total 3 (delta 1), reused 0 (delta 0) To ssh://root@develop.livm.net:/var/www/html/demo/iMedicWare/nsg/helloworld/test/.git/ 64128ef..33f3c84 master -> master my local code changes are NOT in the remote linux server. What am I doing wrong? – bioscorpion Nov 07 '14 at 16:04
  • Also when I create a new file on the linux remote server and then I try to locally pull new file it does not give me the new file: C:\xampp\htdocs\helloworld\test\testlocalgit\test [master]> git pull develop master Warning: Permanently added 'develop.livm.net,192.168.19.70' (RSA) to the list of known hosts. root@develop.livm.net's password: From ssh://develop.livm.net:/var/www/html/demo/iMedicWare/nsg/helloworld/test/ * branch master -> FETCH_HEAD Already up-to-date. Please help. – bioscorpion Nov 07 '14 at 17:04
  • Are you on the master branch in the remote git repo? When you say you create a file in the remote, do you also add it and commit it? – Anas Alkhatib Nov 07 '14 at 17:06
  • On my remote machine here is some commands I just ran so you can see: [root@develop test]# pwd /var/www/html/demo/iMedicWare/nsg/helloworld/test [root@develop test]# ls testgit_new.php testgit_windows.php [root@develop test]# git branch * master [root@develop test]# git status fatal: This operation must be run in a work tree [root@develop test]# So maybe I did not do something on the remote machine? – bioscorpion Nov 07 '14 at 17:11
  • Did you create a bare repository? – Anas Alkhatib Nov 07 '14 at 17:16
  • On the remote machine I created a bare repository like this: [root@develop test]# pwd /var/www/html/demo/iMedicWare/nsg/helloworld/test [root@develop test]# git init --bare . – bioscorpion Nov 07 '14 at 18:12
  • Here is what in /var/www/html/demo/iMedicWare/nsg/helloworld/test [root@develop test]# ls -la drwxr-xr-x 2 root root 4096 Nov 7 12:37 branches -rw-r--r-- 1 root root 66 Nov 7 12:37 config -rw-r--r-- 1 root root 73 Nov 7 12:37 description drwxr-xr-x 8 root root 4096 Nov 5 11:53 .git -rw-r--r-- 1 root root 23 Nov 7 12:37 HEAD drwxr-xr-x 2 root root 4096 Nov 7 12:37 hooks drwxr-xr-x 2 root root 4096 Nov 7 12:37 info drwxr-xr-x 4 root root 4096 Nov 7 12:37 objects drwxr-xr-x 4 root root 4096 Nov 7 12:37 refs – bioscorpion Nov 07 '14 at 18:46
  • This is getting too difficult to troubleshoot in comments, I suggest you restart the process and list what tutorial/instructions you are following in a new question. But also check other answers on stack overflow http://stackoverflow.com/questions/7632454/how-do-you-use-git-bare-init-repository If you can't figure out try to reach out to me. – Anas Alkhatib Nov 07 '14 at 20:55
0

It turns out I needed to add a hook in my git directory. Now my local and remote GIT works great! I used post-update hook:

[root@develop hooks]# more post-update
#!/bin/sh
#
# An example hook script to prepare a packed repository for use over
# dumb transports.
#
# To enable this hook, rename this file to "post-update".
# exec git update-server-info

GIT_WORK_TREE=/var/www/html/demo/iMedicWare/nsg/websiteactualwebdir git checkout -f

I found and followed these two tutorials to guide me on this: http://toroid.org/ams/git-website-howto http://danielmiessler.com/study/git/

I needed to learn a bit more about bare versus regular repositories and hooks, which is what I originally missed.