I'm using a box as a shared repo, and my team connects to it via ssh.
What I do is:
Create an empty git repository on the central machine git init
Then from each workstation do something like git clone ssh://user@central-box/Users/user/Projects/my-project/.git/
This works nice, but git keeps yelling at me every time I make a push something like this:
Is there a better way of sharing a repo over ssh.
IMPORTANT: I'm well aware of the existence of gitosis
and tools like that, I do not want anything fancy. Just sharing a .git repo over ssh.
Thanks
Under your repository name, click Settings. In the "Access" section of the sidebar, click Collaborators & teams. Click Invite a collaborator. In the search field, start typing the name of person you want to invite, then click a name in the list of matches.
On the host machine you should do
git init --bare
Because you don't need the actual files, just the repo.
If the warning message is on a FIRST push to a repo, and no one has touched it, do a
git push -f
Otherwise, this error means your branch scheme isn't correct. You should NOT be editing the branch origin/branchname. You want your own local branch called branchname, then when you are ready to check in your code you do
git commit
git pull
git push
And you will push from your local branchname to origin/branchname.
Edit
I would like to see the output of this command in your local repo:
git branch
You should not see the word origin or your server name anywhere in the output
In addition to bwawok's solution, you'll need to watch out for permission issues. By default, when git creates files on a user's behalf, their permissions are sourced from the user's umask and their group is set to the user's default group. For common umasks and default groups, this will break a shared repo, since such files will be unmodifiable by other users.
Fortunately, git can be configured to do the right thing in this situation: Take a look at the --shared
option to git init
(or the core.sharedRepository
setting). The simplest option is probably --shared=group
, which grants write access to all users in the "git" group.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With