0

I am working in a team on a git project and I really don't understand the process we should be following.

  1. I clone the project I am working on from Github
  2. I then checkout the develop branch to do my work
  3. I do a git add .; git commit -a to add my new files

But as I was working some of the other team players added new files so now Git gives me a error on git push.

What command should I run right before my push to see if anyone changed anything?

4

3 回答 3

3

Using git fetch <remote repo alias> will allow you to preview upstream changes in your develop branch.

You would then want to either merge those changes into your local work, or rebase your local changes on top of the remote work, then try push to the remote repo again.

Here's how you would merge the remote changes:

git merge <remote>/develop

And this is the command you would use to rebase instead:

git rebase <remote>/develop

Both would get you the same end-state for your develop branch.

于 2013-04-25T14:20:50.050 回答
3

I believe you are looking for git pull.

This command will perform a git fetch to get the changes made by your colleagues. Then it would try to perform git merge which will merge their changes onto your local working tree.

If the merge is not successful you will need to resolve the conflicts.

Then you will be able to perform git push and your colleagues will need to pull your changes before they push.

P.S. If you have trouble using this process you could use a visual git client like GitHub, Tower, SmartGit or others.

于 2013-04-25T14:33:34.733 回答
0

If you do git git fetch will retrieve the updated. After that you can check how the repository is doing git status that will show you the status of your clone compared with the one you cloned from.

于 2013-04-25T14:24:57.940 回答