How to use a different set of ssh keys to pull from git [duplicate]
user1 has checked out source code under ~/proj1 using his ssh keys stored under ~/.ssh user2 would like to do a "git pull" to synchronize the changes under ~/proj1 and he would have to do this u开发者_开发技巧sing his ssh keys.
user2 modified ~/proj1/.git/config to reflect url as user2@host:/foo/proj1.git What would be the procedure to accomplish a git pull or a subsequent push using user2's credentials?
I'm not sure I completely understand here...
Both users are logged in under the account of user 1 ? otherwise there would actually be two folders ~/proj1 one in each of the users account's home folder.
regardless of this detail what I understand is that you would want both users to share the same workspace. this to me sounds like a very bad idea. To make a comparison it would be like installing two steering wheel in a car so that both front seats become drivers.
Why would you want two different users using the same workspace ? This completely defeats the purpose of git or any other source control mechanism for that matter.
If they both work in the same work-space how do you discern which user made what changes. Of course, if you find a solution to this problem the actual actions performed against git will be done with the user's own certificate but that does not mean the changes are actually his to begin with. Effectively this will remove any usefulness of knowing who made what action since it will become impossible to know exactly who did what when.
The best (and only workable) solution to this dilemma in my opinion is to not even try it. Have each user do a git clone under his own home folder. Each user with his own git instance configured to use his own credentials and demographics and each will push changes to whatever instance they cloned from.
If you want them to share changes without going through the central instance they can always pull from each-other or push to each-other (either will achieve the same effect). This is actually the beauty of git as opposed to SVN. The "central" repository doe snot have any special function, it is so only semantically because it fits your workflow. All repositories are on equal footing and you can push and pull to or from any one of them. this all works because each have their own repository to work into. I am quite certain we can solve this issue and allow sharing through cleverly crafted aliases and scripts but why !?? Sharing repository will make things needlessly difficult.
If you do not have a centralized repository you could have user 2 clone the repository of user 1. Not super pretty as two depends on 1 for his normal workflow but it works within git natural workflow.
You have to use the ~/.ssh/config
file to define your keys for your repositories, as described here.
(I'm voting this question as duplicate since it's really close to the other one)
精彩评论