tags:

views:

69

answers:

1

So I've got a local repository with two branches: master and shop. I've also got a bare repository, and a remote repository. I can push and pull fine between all of these, but there are some files that keep getting lost. I'm doing the following:

From my local root:

git push barereposerver shop

All is well. Whoo, we pushed there. And then from the remote root, after doing a git init and git remote add bare ssh://blahblahblah/blah.git, I'm doing:

git pull bare shop

But for some reason, I've got a few files that aren't coming across.

I know I haven't given much information, but I'm very new to git, and I don't know the right terminology yet. I'd love for you to ask me some questions and see if you can help me through this one. Thanks so much!

Update: a sideways version of what I'm looking to do. I'm looking to get from other -> other, via a bare repo: http://droplr.com/wEB1q

+1  A: 

From your diagram, it looks like what you have done is:

  • push to the bare (from local)
  • and then, from remote, register bare repo, and pull from bare

"From my local root: git push bareserver shop"

Which is:

alt text


the set that does not come through are a new group of files that exist on the local branch, but for whatever reason, do not get pushed to the remote branch

Well, did you actually add and then commit those files, before attempting to push your local repo? (see this question for instance)


From the comments, here is how we tracked together the root cause of this issue:

Another way to troubleshoot is to note the SHA1 of the local commit (which contains your files) and the SHA1 of what you are getting on the remote side (after pulling from bare): if it is not the same, that explain the different content, but you can also search that SHA1 (obtained on remote) on the bare repo and on the local repo, to check to which commit that SHA1 (which lacks some files) refers to.

Would that be this number? 591178c18126be127eaa417fa6b3be86c0fce969 If so, I get the same number on remote and local.

A SHA1 is indeed such a number. If it is the same on local and repo, the content must be the same. Try (if you do not have any current modification on remote) a git reset --hard (again, on the remote repo); check first that you have the right branch checkedout in your remote repo)

Side-by-side, the two results from git log:

alt text

and side-by-side, the two folders with different files:

alt text

if the SHA1 is the same, then the missing directories should not be part of the local commit.
Try to clone your local repo in a second local repo and check if you see the same content in both local repos.

Strange. When I cloned the local repo to another local repo, the files were missing again. I ran the clone command from the correct branch. Ideas why this would be?

This is a side-by-side of the entire processes for cloning and displaying the different results:

alt text

Right now, the fact that the directories are missing in a local clone is proof enough that those directories are not part of the local repo commits in the first place. Are those directories empty? (because even if added, they wouldn't be committed)

Yep, they're totally empty.
They're directories that are originally created as empty but required for a WP plugin to be able to write to in order to add things.
Per this SO question I can add a .gitignore gonna try that. Until this point, in two weeks with git, I've seen this documented nowhere. Seems like a big issue to be communicated so rarely, or am I missing something?

This is actually an important design decision, part of what makes Git a file content management system (see Popularity of Git and Git versus SVN).

Those directories, once added with a .gitignore in them, are now pushed/pulled successfully.

VonC
Sorry I was unclear, I should have included arrows :)This is what I'm doing; I'm pushing to bare from local "other". Then I'm registering bare and doing "git pull bare other" from my remote repository.
Joshua Cody
@Joshua: that is not what you were saying in your question: "From my local root: `git push remoteserver shop`" means you are pushing from local to remote, not to bare. See my edited answer.
VonC
Hmm, again, my lack of understanding coming in. So at the root of my server, I created a bare repo. Then, at my local root, I did **git remote add servername ssh://go/to/barerepo.git**. And to push to the bare from local, I do **git push servername shop**. Am I missing something? My bare is at the root of my server, then my remote where I'm pulling to and accessing via URL is on the same server, although in a subfolder within my public folder.
Joshua Cody
So are we just having a semantic misunderstanding? I'm pushing to a bare repo at the root of my server, I simply called it remoteserver in my question, which was indeed confusing. Then I'm pulling from that bare repo to a remote repo, where people will access the site.
Joshua Cody
@Joshua: I confirm the "semantic misunderstanding" :) I would register bare repo as "bare_servername" in order to avoid any confusion ;) That said, could you give some information about the file which aren't pull? Is the issue reproducible (from another remote repo?) Are the missing files always the same?
VonC
Great questions. I've made changes to two files since I last pulled. And one set of changes comes through, but the other set of changes does not come through. The set that comes through was a simple update within a file, and the set that does not come through are a new group of files that exist on the local branch, but for whatever reason, do not get pushed to the remote branch. Is there any way to check if these pass through the bare repo?
Joshua Cody
Creating a new setup like so: `git --bare init` at the root of the server. Connect the two with `git remote add barerepo ssh://url/to/repo.git`. Add the master with `git push barerepo master`. Switch to the shop on local, and add the shop with `git push barerepo shop`. At the remote location, go a `git init` in an empty folder. Do a `git remote add bare ssh://url/to/repo.git`. Then add the master with `git pull bare master`. Next, create a shop branch, switch to it, and do a `git pull bare shop`. Is this the jist? Because I'm still missing the same old files :(
Joshua Cody
All right, I tried to create a new folder at local and pull the shop branch from the bare repo to it, and I still am not getting these 5 files within a folder. There might be more files I'm not getting, I'm not sure. But it seems they aren't being properly pushed to the shop branch of the bare repo in the first place. Do you know any way I can troubleshoot this?
Joshua Cody
@Joshua: just completed my answer with a new question. Note: to check what you are not getting, you can clone back your remote repo, and do a diff (WinMerge on Windows for instance) between local and remote-cloned-on-local.
VonC
Von, I have definitely added and committed the changes. I'm using GitX on Mac to do my adding and committing, but a `git status` shows that my working directory is clean. I've manually gone to those directories and done a `git add .` just in case, but nothing doing there. I've tried git diff, but it doesn't seem to give me a list of files, but an entirety of all of the updates, which seems to be too big to sort through and find an individual filename :/
Joshua Cody
@Joshua Another way to troubleshoot is to note the SHA1 of the local commit (which contains your files) and the SHA1 of what you are getting on the remote side (after pulling from bare): if it is not the same, that explain the different content, but you can also search that SHA1 (obtained on remote) on the bare repo and on the local repo, to check to which commit that SHA1 (which lacks some files) refers to.
VonC
Would that be this number? 591178c18126be127eaa417fa6b3be86c0fce969 If so, I get the same number on remote and local.
Joshua Cody
@Joshua: A SHA1 is indeed such a number. If it is the same on local and repo, the content *must* be the same. Try (if you do not have any current modification on remote) a `git reset --HARD` (again, on the remote repo); check first that you have the right branch checkedout in your remote repo)
VonC
Wouldn't accept --HARD, had to do --hard. Side-by-side, the two results from git log: http://droplr.com/wG47N and side-by-side, the two folders with different files: http://droplr.com/wG63a
Joshua Cody
@Joshua: if the SHA1 is the same, then the missing directories should not be part of the local commit. try looking a git log on both side, or try to clone your local repo in a second local repo and check if you see the same content in both local repos.
VonC
Strange. When I cloned the local repo to another local repo, the files were missing again. I ran the clone command from the correct branch. Ideas why this would be?
Joshua Cody
This is a side-by-side of the entire processes for cloning and displaying the different results: http://droplr.com/wGzem
Joshua Cody
Off to bed, but will be back to keep fighting this in the AM. If we can get to an answer, should I mark the answer we're commenting on as answered, or would you like to simply re-post as a new answer so I can mark the correct part more clearly?
Joshua Cody
@Joshua: If we find a solution, I will edit my answer to reflect it. Right now, the fact that the directories are missing in a *local* clone is proof enough that those directories are not part of the local repo commits in the first place. **Are those directories empty?** (because even if added, they wouldn't be committed)
VonC
Yep, they're totally empty. They're directories that are originally created as empty but required for a WP plugin to be able to write to in order to add things. Per this question http://stackoverflow.com/questions/115983/how-do-i-add-an-empty-directory-to-a-git-repository I can add a .gitignore gonna try that. Until this point, in two weeks with git, I've seen this documented nowhere. Seems like a big issue to be communicated so rarely, or am I missing something?
Joshua Cody
@Joshua: this is actually an important design decision, part of what makes Git a **file content** management system (see http://stackoverflow.com/questions/995636/popularity-of-git-mercurial-bazaar-vs-which-to-recommend/995799#995799 and http://stackoverflow.com/questions/1438662/which-of-the-two-is-bettergit-or-svn/1438697#1438697). Could you confirm to me that those directories, once added with a `.gitignore` in them, are pushed/pulled successfully?
VonC
100% working; thanks so much!
Joshua Cody
@Joshua: outstanding! I just updated my answer and documented the all troubleshooting process for other to follow.
VonC