What does fork and push upstream mean for github?

I am currently using GitHub for a project with my college professor. Since I am not too familiar with GitHub, I cannot understand the instructions that he sent me.

I was hoping that someone would be able to interpret them for me and help me understand this.

The student must use a GIT hub and use Project7. Fork his own repository and a new branch upstream to the main repository project

I am a little versed in GitHub and its repositories, and now I am reading branches. But I still don't understand how to implement the above instructions using commands.

+8
git github
source share
3 answers

The first part of the instructions is perfectly clear. You need:

  • Log in to GitHub, go to the professor’s repository and click "Fork".
  • Find the SSH URL for your repository fork and clone it locally using something like:

    git clone git@github.com:whoever/whatever.git 
  • If you run git branch -r , you will see that you have a remote tracking branch origin/Project7
  • You need to work in this branch, so you need to create a local branch based on origin/Project7 . You can do it with

     git checkout -b Project7 origin/Project7 
  • Now you have to make your development and create commits, as usual, to advance the Project7 branch.

Now for the part that is a bit unclear to me:

[...] push the newly developed branch upstream to the main project repository

It could mean:

(a) That you return your branch to your own forked repository on GitHub. You can do it with git push origin Project7

On the other hand, this may mean (b) that your professor added you as a co-author to his repository on GitHub and wants you to click on a new branch in your repository. In this case, you can do something like:

 git remote add professor git@github.com:professor/whatever.git git push professor Project7:WarDoGG-Project7 

This will cause your Project7 branch Project7 move to a new branch in the professor's repository: WarDoGG-Project7 . Or he may want you to just push your branch back to the original Project7 , in which case you can just skip part of the command :<destination-branch> .

I think situation (a) is more likely, but you should check.

+6
source share

I understand from the instructions that:

1) You must go to the main page of the github project (after logging in) and click the top right "Fork" button. With this, you forked the main project into your github account.

2) Cloning your forked project to your computer:

3) In the local git repository: > git checkout -b Project7 origin/Project7

4) Work on the code ....

5) Make changes to the github repository.

6) Make a pull request on github to the main repo.

+2
source share

He told you to download the repository, and then switch to the Project7 branch and unlock your branch. You should be able to clone a forked repo by following these instructions (works just like a regular clone, except that you must first develop it on github):

http://help.github.com/fork-a-repo/

Then, after you clone it, switch to the Project7 branch

git checkout -b newlocalbranchname origin / branch-name

Then go back to the branch:

git push origin branch-name

+1
source share

All Articles