Question

I am a novice programmer, and completely new to GitHub. I am collaborating with a colleague on a project he has been working on over the years.

So Far:

He created a repository and loaded up all the initial files. I forked it into my account, so that I could work on it separately.

Now:

How can I make a commit to my repository and share it with him, so that he can check out the changes and incorporate them into his repository IF he likes the changes?

I know there is a lot of information on GitHub, but I'm not even sure where to start. Any help is greatly appreciated.

Was it helpful?

Solution 2

There are many ways to do this, github recommends pull requests and unless you have no push access to the repository you will need to do this or send patches. There is an example of such a workflow here

git clone git@github.com:<their repo> [optional folder name]
cd reponame (or optional folder name)

If the repository has submodules then

git submodule update --init (if the repo has submodules)
git submodule foreach 'git checkout <their working branch>'

Fork the code. Fork the specific repository you plan to work on. This will give you your own copy of the project. Set up git in the repository you plan to work on.

cd <repo dir or optional one chosen)
git remote set-url origin git@github.com:<your github name>/<your repo>.git
git remote add --track next upstream git://github.com/<their github name>/<their repo>.git

That is your repository set up to help with code. You can do git pull, git push, etc. (this will be to/from your fork). To pull in changes from a branch of the partner repo, just do:

git pull upstream branch

You will not be able to git push to their repo, for that you need to do a pull request.

When you are happy then go to github (your project) and select diff and pull request. This allows you to put in a message and the lib maintainer will get a message to attend to the request. It will also show if your pull request will merge cleanly, it is unlikely to be accepted if the maintainer has to fix code.

OTHER TIPS

Recommended approach in your case is collaborating with your friend.

Here is how:

Add a collaborator

Read this: Will give you basics of git and how to collaborate with others.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top