Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git push/pull between team members local repositories

Tags:

Lets say there is a team with 4 developers. We also have a central repository for our project. Developers push and pull from central repository. Here(in Decentralized but centralized section) it says that its possible to push/pull between team members local repositories.

Each developer pulls and pushes to origin. But besides the centralized push-pull relationships, each developer may also pull changes from other peers to form sub teams...Technically, this means nothing more than that Alice has defined a Git remote, named bob, pointing to Bob’s repository, and vice versa

Now question is how to define remote name bob which is pointing to Bob's repository. If it matters developers possibly use different operation systems.

like image 219
nyzm Avatar asked Aug 16 '13 04:08

nyzm


People also ask

Can I push to someone else's repository?

Using the command lineAdd a connection to your friend's version of the github repository, if you haven't already. Pull his/her changes. Push them back to your github repository. The pull request on github will be automatically closed.

How do I pull my local repository?

Using git pullUse git pull to update a local repository from the corresponding remote repository. Ex: While working locally on master , execute git pull to update the local copy of master and update the other remote tracking branches.

Can a git repo have two remotes?

You can add multiple remotes by using git remote or git config commands or editing the config file. As git can group multiple remotes, you can follow any of the following ways to configure multiple remotes to push simultaneously(no need all). You can set multiple remote URLs to a single remote using git remote.


2 Answers

If you establish a user account on the host and access permission on the repo, someone else can push/fetch over SSH with or without establishing a named "remote".

git push user@host:/path/to/repo branch

If you share code frequently, you can setup a named remote to remember the server path:

git remote add remotename user@host:/path/to/repo

If it's OK that sharing involve close coordination (and probably very loose security), you can fire up a short-lived git daemon on the "master" as needed: git equivalent of 'hg serve'? In this case, the above sharing commands still apply, but the user@host:/path will be replaced by git://host/. See also git daemon documentation.

Alternatively, you could setup a separate dedicated repository to use for intermediate sharing: How do I setup a staging repository in git?

like image 135
Brent Bradburn Avatar answered Sep 29 '22 01:09

Brent Bradburn


It's a very common thing like Alice and Bob need to work on some functionality together. In the mean time, the development should be carried on different branches by different developers.

Simple approach would be:

  • Create a new branch sprint_1, Alice and bob checkout to sprint_1
  • All the changes related to functionality should be done here
  • Push and pull operations should be performed using

    git pull origin sprint_1  and git push origin sprint_1
    

When the changes are done and sprint_1 has a stable code, it could be merged with other branch. If the code on sprint_1 has come a long way, it is advised to rebase the branch than merge to avoid conflicts or cherry picking.

like image 40
Bijendra Avatar answered Sep 28 '22 23:09

Bijendra