简体   繁体   中英

Egit / Github - Get files from partner

This may be a stupid question, but after several times trying to get this right I'm getting frustrated. I want to use github to host my project, we are 2 people working on the project and the aim was to share the work. And help each other.

I managed to create the resepetory, and committing to master branch. If the other guy deletes the whole project he gets the latest updates, but I'm sure this is not the way its supposed to work.

Lets say I commmit a new class file. I commit this file, how could the other person download this file? We've tried pull, synchronize etc etc without any luck. The only way we have found to give him "my" latest updates is for him to delete all content and make the project from scratch.

What am I missing? How can we synchronize workspaces? So I can see and download his changes when i open Eclipse? (We are not working in the same class). So really all I want to do is download he's latest commits.

EDIT : My solution was that my partner was working in a copy of the local git workspace. So instead of modifying the local repo he was modifying a copy of it inside the Eclipse workspace. And because of this nothing updated when he did the pull. I also switched from Egit to GitHub command line tool, and I'm in love. Thanks everyone :)

Normally with GitHub, all of what you have described works perfectly, I have not had any kind of similar problems.

One thing about git, a commit is a bit different than a commit in SVN. With git, you use push and pull to interact with your remote repository.

I am not sure what you mean when you say:

If the other guy deletes the whole project he gets the latest updates, but I'm sure this is not the way its supposed to work.

That being said, I have never used Egit, I prefer to stick to the command line for all my git needs. I have had issues with other software (Sublime Text 2) where I would have to exit the editor, then run all my commits and other git actions. I do not know how well Eclipse plays with git in general.

Try to have your partner run git remote -v just to make sure he is tracking the repo properly. Also, do you know if he set up an SSH key for GitHub, or you sending your pushes and pulls via https?

Keep in mind this is pretty hard thing to help you out with since I am not sitting at your computer. GitHub Help has some very good walkthroughs on setting up git and remote repositories.

Also, I highly recommend the time to go through CodeSchool intro to git. If this is your first time using Git, this is the best starting point.

There are much more complicated scenarios, but basically, you need to "push" your commits to the upstream, and pull your colleague's.

Clone the repo. By cloning it you will guarantee that it has an "origin", the github remote. You make changes in your local repo, committing them as you go. When you are at a milestone, use Team > Push to push all of your commits to github. Your colleague will pull them, as described below.

When you try to push, you may discover that your colleague has pushed changes and that git will not allow you to push until you merge. Try Team > Pull which will merge the remote changes into your local repo. If there are no conflicts, you can now push. If there are conflicts, fix them and then commit. Then push.

This is a substantial simplification but may get you started. The main point is that the equivalent of a SVN commit is, in git, two, maybe three, operations: add, commit, push. Git pull is vaguely analogous to SVN checkout.

Take a day to read up on git. There's great documentation at GitHub. Once you get the hang of it, you'll love it.

When using git to collaborate on a project, you are managing both a local and remote repository. When you commit , you are only saving changes to your local repository. After committing, you need to do a push in order for your changes to be saved to your remote repository. After doing that, if your collaborator does a pull he will get your changes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM