0

I am connecting to my shared server with git. Git was already install on the server, so I git init my existing project then cloned from it locally. So far so good. I tested making some changes and pushed. This failed, but with the help of this question, I was able to push to my remote repository. Here is a sample successful push response:

git push origin master 
Password: 
Counting objects: 3, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 262 bytes | 0 bytes/s, done.
Total 2 (delta 1), reused 0 (delta 0)
To user@address:/var/chroot/home/content/59/6030759/html/git-directry
   ca4fd96..fe56682  master -> master

Now it seemed to be working, but no changes take place remotely. I tried sshing in to see if I could git pull or git status, but then I get the error:

-bash-4.2$ git status
fatal: This operation must be run in a work tree
-bash-4.2$ git pull
fatal: /usr/libexec/git-core/git-pull cannot be used without a working tree.

This is a godaddy server, so potentially they are blocking my pushes but I have setup my ssh key. Any ideas on why my commits are not getting through?

Edit: Server has git version 1.7.1, mine is 1.9.1

Community
  • 1
  • 1
hodale
  • 717
  • 1
  • 6
  • 13
  • Why do you think no changes take place remotely? You appear to be running the `git status` command from your home directory on the remote server, not from the actual git repository. – chepner Nov 13 '15 at 21:08
  • There is no evidence of problems with pushing data to the remote. So just to be sure, try to clone from the remove into into tmp directory and then check the status. – marbu Nov 13 '15 at 21:39
  • I forgot to mention my tests: I tried adding a test file and pushing that and it doesn't show up (even when getting succesful push). @chepner when I run the git commands I am in the repository, otherwise it would say fatal: not a git repository. – hodale Nov 13 '15 at 21:52
  • 1
    I suspect that on the remote you have a _bare_ repository. That means it's contents correspond to the `.git/` folder of normal clones. They do not have any checked out files. However, commands like `git branch -a` or `git log master` should show you that indeed you have a git repository with the changes recorded. – Michael Wild Nov 13 '15 at 22:02
  • it is a bare repository (I knew that because of the steps I had to follow when pushing initially failed). I had not check git log and that shows all my latest test commits. But clearly the files are not being changed. When I make changes to files, or create new ones, they are not showing up. – hodale Nov 13 '15 at 22:17
  • This isn't quite *literally* true, but as @MichaelWild already noted, on a bare repository, there are no files. (More precisely, there is no "work tree".) Therefore, there is nothing to see—you can't see any file updates as there are no files to update—and `git pull` makes no sense (because its second half is `git merge` and there's no way to do a merge). Files (more precisely, work trees) only appear in non-bare clones, like the one where you do your work. If there are any files left over, they're from when you had a non-bare clone, and git is now ignoring them. – torek Nov 13 '15 at 22:46
  • I looked back at why I made it a bare repository and I think that was a mistake. I was not able to make pushes because I was checked into the master branch remotely. I checked out a new branch remotely and can not push. – hodale Nov 13 '15 at 23:47
  • Based on the question and your comments, I really suggest you start reading up on Git. There are a number of freely available, excellent e-books I can recommend, such as [Pro Git](https://progit.org/) or [Git in the Trenches](http://cbx33.github.io/gitt/). For a more comprehensive list, refer to [this collection](https://github.com/vhf/free-programming-books/blob/master/free-programming-books.md#git). – Michael Wild Nov 15 '15 at 09:54

0 Answers0