.gitmodules changes with multiple git users, causing a constant headache

Let me first say that I am Git n00b and relatively new to version control. We have done a good job using Git on Windows since Visual Studio so far, and everything seems to be going well. However, what annoys is the .gitmodules battle that we currently have in our hands.

If UserA creates a new submodule, the path in .gitmodules for "origin" will look something like this:

 ssh:// usera@myserver /Repositories/NewModule 

When I, user B, pull the changes from the server, I download a copy of .gitmodules with this entry. When I try to initialize a new submodule, I inevitably cannot load from myserver, because I am a user and save only my SSH key for userb. I need to modify .gitmodules to display my username:

 ssh:// userb@myserver /Repositories/NewModule 

And I end up pushing this change.

Thus, we get a recursive problem for us, changing the username from UserA to UserB or vice versa. When any of us pulls / clicks on the server.

Any ideas how we can solve this problem? Maybe the general user account is for us as submodules? It can be done? How? Any other ideas out there or someone who solved this problem before?

+4
source share
3 answers

One option is to install Gitosis on myserver. Then each cloned URL will be the same as the ssh:// git@myserver :/path/to/repo.git form. Gitosis allows developers to register SSH keys and allows you to define authorization and authorization rules.

You can also roll your own by hacking ~git/.ssh/authorized_keys to myserver and authorizing by modifying this sample update hook .

+1
source

Short answer: "Check if you can use relative paths for submodules."

Detailed answer: we have a submodule that is used by several applications. We saved the submodule in the same repo.

The structure is like this, repo

  | -app1
 | -app2
 | -submod

When we clone the application, app/.git/config gets the URL with the current user, for example ' userA@repo.com '. In .gitmodules applications, we specify the URL as ../submod . Thus, when we do git submodule init , git generates an absolute URL for the submodule from the relative URL that we specified in .gitmodules .

+1
source

Another, using gitosis, as gbacon said, you can change your workflow a bit.

When working in a public branch (a branch shared with others in a team), submodules from the public branch of a single official repository are always used. And instead of using your username to pull from the repository from the submodule, use one common user common to the team. This user will have read-only access to the repositories.

The downside is that if you want to click on the shared submodule repository, you need to do this from another working copy using your username. This is sometimes a problem, and sometimes not. Depends on the relationship between the modules and your process.

0
source

Source: https://habr.com/ru/post/1315591/


All Articles