2

I followed these instructions: How to convert a normal Git repository to a bare one? then I tried to push to the main repo, I just changed some text in a test.txt file.

When I pushed it, job was done with output

1 file changed, 1 line added...

but when I connect with FTP to see my test.txt file it wasn't there!

this is the command I used:

git push ssh://username@domain:22/~/repo

do you think I should change the command to this:

git push ssh://username@domain:22/~/repo/reponame.git master

Because I did this now and I am waiting for response because its taking a long time..

Community
  • 1
  • 1
TooCooL
  • 20,356
  • 6
  • 30
  • 49

1 Answers1

1

A bare repository doesn't have a working copy:

but when I connected with ftp to see my test.txt file it wasnt there!

which means, there are no checked out files, like test.txt.

If you wanted to verify that it exists (in the .git/objects database), use any of the following (on that server):

git ls-files -- test.txt
git archive HEAD -- test.txt > test.tar

git cat-file -p master:test.txt

or just clone the repo to another location to check that it contains the file.

From the client you used to push, you can do compare it to the remote

git remote add server ssh://username@domain:22/~/repo
git remote update --prune

By doing e.g.

git log --left-right --graph --oneline HEAD ... server/master

You'll see exactly which commits are in only one of the respective branches. Alternatively

git diff --stat server/master

to list any difference between the local HEAD and the remote master branch

sehe
  • 374,641
  • 47
  • 450
  • 633
  • I need to check it via SSH in the server right? because I just did ls and it didnt show the test.txt file – TooCooL Mar 28 '13 at 07:36
  • @TooCooL I get the impression you _didn't_ read the essential part about "bare repositories" - they won't contain the files. Git is not FTP. And if you need a working copy, you probably shouldn't be using a bare repository. – sehe Mar 28 '13 at 07:37
  • the bare repository is in my main web folder. doesnt it mean that if I push the changes that I make the site will update? Or do I have to make one bare and one non-bare repos in the server then push the changes in the bare repo, then pull the changes in the non-bare repo (live site) in the server? – TooCooL Mar 28 '13 at 07:40
  • @TooCooL that second option sounds like the best thing to do. You **might** push directly to a non-bare repository, but [you'll run into bumps when pushing changes to the checked out branch](http://stackoverflow.com/questions/2816369/git-push-error-remote-rejected-master-master-branch-is-currently-checked). (You can solve that by using post-receive hooks, or by having another checked out branch and pull on the server after pushing to the master branch, but that's usually more complex to understand for "git newbies") – sehe Mar 28 '13 at 07:42
  • can I have branches in bare repo? what if I make a new branch in the server, push the changes there, and then merge those changes from the branch & master? yes I am newbie in this remote thing, I have been working with git for a long time but only localy – TooCooL Mar 28 '13 at 07:45
  • Sorry about the newbie wording, I seemed to remember it was stated as such in the question (different question, I must have gotten confused). And, yes, you can have many branches in any repository. You can push to a specific remote refname, e.g. `git push remote master:push_master` will update/create a remote branch 'push_master' from the local 'master' branch. On some of my boxes, I use a scheduled tasks to `git pull push_master`. Just checking: aren't you confusing branches and _working trees_? Because, a bare repo, by definition, does not have a working tree. – sehe Mar 28 '13 at 09:05
  • 1
    thank you for helping me, I found a good article about this: http://joemaller.com/990/a-web-focused-git-workflow I came up with this idea after talking with you here, and then I found this article just like I wanted to do it. – TooCooL Mar 30 '13 at 01:11
  • That's.... TooCooL :). In the pull script, consider `git stash save -u` to retain any local edits, in case anyone ever modified the actual server working tree. – sehe Mar 30 '13 at 01:33