Suppose we have three user account: gituser, juan and jerry
gituser is used for git remote repository
juan is used for dev1
jerry is used for dev2
(Note: all these three users all sit in the same machine named driver because of the shortage of machine)
Let’s see how git common commands work
1 create git remote repository
OK. An empty remote repository has been created.
2 juan(dev) clone remote repository
Juan sucessfully downloaded the remote repository which is empty. In order to clone conveniently, I have configured password-less access for user ‘juan’. See reference at the end of this article to see how to configure password-less access.
In the picture above, I used ip ‘127.0.0.1’ in clone command since gituser which is the user of our remote repository sits on the same machine with user ‘juan’ and ‘jerry’. You can change ip to be the one your gituser will use in your case
3 create a master branch and commit some code by ‘juan’
origin is the default name of our remote repository
Here we use command ‘git push origin master’ to push exisitig code to remote branch(master) on remote repository
4 create a new branch based on master branch. Make some changes on new branch and summit the changes to the new remote branch
5 jerry clones code and switched to new_branch. juan updated branch new_branch. jerry then updated her code to be latest on new_branch
Here you can use pull instead of the combination of fetch and merge
reference: password-less access
(take juan as an example)
1 generate public key for juan
2 copy juan’s public key to gituser