Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "fork" and "push upstream" mean for GitHub?

Tags:

git

github

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

I was hoping someone could interpret these for me and help me understand it.

Student should use GIT Hub and use the Project7 branch. Fork his own repository and push newly developed branch upstream to the main Project repository

I know a bit about GitHub and its repositories and I'm reading up on branches now. But I still cannot understand how to implement the above mentioned instructions using commands.

like image 895
YD8877 Avatar asked Apr 26 '11 01:04

YD8877


People also ask

What does it mean to push upstream in git?

pushing " upstream " means that your current branch B has remote/B has its upstream branch. Ie: branch. B. merge is set, when your are pushing the " upstream " branch. Ie: when pulling to B , git knows what branch to pull (as well as which remote repo: branch.B.remote )

What does upstream mean in GitHub?

Like the literal meaning, upstream refers to something which points to where it originated from. In the git world, upstream refers to the original repo or a branch. For example, when you clone from Github, the remote Github repo is upstream for the cloned local copy.

What does forked on GitHub mean?

A fork is a copy of a repository that you manage. Forks let you make changes to a project without affecting the original repository. You can fetch updates from or submit changes to the original repository with pull requests.

Is it OK to fork GitHub?

GitHub is a popular application for managing Git repositories. Anyone can contribute to a public repository. Forking is an excellent tool for copying source code from someone's repository to your repository and contributing to it. The forking workflow is simple to learn and get started.


2 Answers

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

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

    git clone [email protected]:whoever/whatever.git
    
  • If you run git branch -r you should see that you've now got the remote-tracking branch origin/Project7
  • You need to work on that branch, so you need to create a local branch based on origin/Project7. You can do that with:

    git checkout -b Project7 origin/Project7
    
  • Now you should do your development and create commits as usual to advance your Project7 branch.

Now is the part that is slightly unclear to me:

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

This might mean:

(a) That you should push your branch back to your own forked repository on GitHub. You can do that with: git push origin Project7

On the other hand, it might mean (b) that your professor has added you as a collaborator to his repository on GitHub, and wants you to push to a new branch in his repository. In that case you might do something like:

git remote add professor [email protected]:professor/whatever.git 
git push professor Project7:WarDoGG-Project7

That would push your branch Project7 to a new branch in the professor's repository called: WarDoGG-Project7. Or he might want you just to advance his branch by pushing back to the original Project7, in which case you can just miss off the :<destination-branch> part of the command.

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

like image 124
Mark Longair Avatar answered Oct 21 '22 05:10

Mark Longair


I understand from the instructions that:

1) You should go to the main project github page (once logged in) and click on the "Fork" upper right button. With this you have forked the main project to your github account.

2) Clone your forked project to your computer:

3) On your local git repository: > git checkout -b Project7 origin/Project7

4) Work on the code....

5) Push your changes to your github repo.

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

like image 22
grzuy Avatar answered Oct 21 '22 05:10

grzuy