brunodd
brunodd

Reputation: 2584

Git: Get updates from repository

I'm new to Git and after testing and researching how it works there is one question that still is not very clear for me.

I'm gonna use a practical example to better illustrate my question: Let's say I work in a team and have a project folder named my_project and I have 3 files inside it (file-A, file-B and file-C).

I make some changes to file-A and commit to the repository and another team member also makes some changes to that same file and commit the changes to the repository as well.

My question is: How can I get the changes made by my team member in order to update my file-A with his changes?

Could someone please clarify how that process works?

Thank you. Looking forward to hear your thoughts.

Upvotes: 2

Views: 991

Answers (1)

magikid
magikid

Reputation: 308

Git keeps a history of all changes to all files on your local computer. If you want to share changes between team members, you have a few options.

Use a remote repository

With this option, you and your teammates would setup a repository on a site like Github or Gitlab. If you're worried about your code being open to the public, you can always setup a local instance of Gitlab inside your network. Your remotes would look like:

$ git remote
github

With this method, each team member would setup a remote to the Github repository and then push their changes to Github while the other teammates would pull down the changes. Your workflow would look something like:

Hack on the files
$ git pull github
Fix any merge problems
$ git push github

Use a push/pull directly from team members

In this method, you would add a remote for each of your teammates computers. Your remotes would look like:

$ git remote
jane
paul
olivia
magikid

There would be no central repository and your workflow would look something like:

Hack on files
$ git pull jane // to get her changes
$ git pull paul // to pull in his changes
$ git pull olivia // grab her changes
$ git pull magikid // grab his changes

The big difference here is that there is no central repository of all the changes. Each team member would have all of the changes that they had pulled on their computer.

Upvotes: 2

Related Questions