2

Whenever I push my local code to my staging server (a remote repository) they don't show up but instead appear in 'git status' as deleted. How can I get this set up properly?

I so my work in my local repository ('development' branch). Other non-Git people are putting files directly on the server (and the server does some period updates itself as well). I have set up the server to be a 'staging' branch. When I want to push my code to the server. I add / commit changes made on the server in the 'staging' branch. I then pull them down to my local 'staging' branch. I merge them with my 'development' branch. Then I push the 'staging' branch back up to the server. Unfortunately this is no longer working - my new files get marked immediately as 'deleted' and my changed files get marked as 'modified'. How can I resolve this condition? The files don't even appear in the directory.

I suspect this has to do with a change I made up there to resolve the fact that this is a live staging server and I wanted to be able to push to the checked-out branch.

git config receive.denyCurrentBranch ignore 

Any help, ideas, scorn, ridicule, resolutions, appreciated.

Oddible
  • 121
  • 1
  • 8
  • Sounds like you are pushing to a non-bare repository. The general consensus is that you use a bare repository to coordinate and share changes from multiple programmers. Then your deployment could be a non-bare repo that pulls from your shared bare repo. – Wolf Jan 31 '14 at 18:20
  • True. My problem is I'm in an environment where not everyone is using Git. Sounds like the answer is to just remove Git from the remote and just FTP back and forth, merging on the local. Unfortunately Git seems to have no real solution for mixed Git / non-Git environments. – Oddible Jan 31 '14 at 18:28
  • Are you saying that you're working with developers who are not using source code control at all --- just pushing changes directly to your deployment? – Wolf Jan 31 '14 at 18:35
  • Yes, sadly (such as designers doing CSS/SASS, etc). My current resolution is to go back to create a dummy branch on the remote which I switch to before I push. I guess I could just reset --hard. – Oddible Jan 31 '14 at 18:37
  • Git definitely has tools for working with mixed environments (look at git-svn), but working in an environment where some of you are using git and some are just messing about with files is not going to work well. You could set a post commit hook on the parent repo to copy files to the final destination if you always want to publish what you push immediately. This is convenient but could be dangerous. – Ilion Feb 01 '14 at 02:22

1 Answers1

0

Are you saying that you're working with developers who are not using source code control at all --- just pushing changes directly to your deployment?

You can setup a bare repo which would allow you:

  • to add and accept any files from another working tree (not managed by git)
  • to push your own file (after having pulled first, in order to take into account those files added by the non-git users)

The first point can be done by a cron job which would, for instance every minutes, do a:

cd /your/bare/repo
git --work-tree /path/to/non/git/workingtree add -A
git commit -m "add files from non-git users"

(you might want to adapt this naive implementation in order to commit only if files were added)

The second point needs to be completed by a post-receive hook on that bare repo in order to automatically copy your files on that non-git user repo.

This isn't an ideal solution as there is always the possibility of race condition: it needs to be more robust, possible with some chown or other right management, preventing non-git users to do any modifications while you are pushing -- updating the working tree.

But it shows you a possible way to make the two world collaborate with each other.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250