Open Source Comes to Campus/Curriculum/Git/Students: Difference between revisions

no edit summary
imported>Shauna
No edit summary
imported>Shauna
No edit summary
Line 99:
The copy of the repository you have on your computer is called your "local" copy. The copy on Github is a "remote". You can see what remotes are associated with your local repository by typing the command:
 
<code> git remote -v</code>
 
You should see something like this:
<code> origin urlhttps://github.com/$yourusername/$repositorynameyour-repository-name (fetch)</code>
<code> origin urlhttps://github.com/$yourusername/$repositorynameyour-repository-name (push)</code>
 
Origin is the default name for your remote repository. The URLsurls you see should correspond to the URLs youurls used in the "git clone" command above. ThereRight arenow separateyour listingsonly remote is your personal copy of the repository. That's fine for "fetch"pushing andchanges, "push"since you need to go through the personal copy to submit pull requests. But what if you want to get an up to date version of the becausemain [repository??????] To do this, you'll need to add the main repository as a remote.
 
To do this, type:
Right now your only remote is your personal copy of the repository. That's fine for pushing changes, since you need to go through the personal copy to submit pull requests. But what if you want to get an up to date version of the main repository?
 
<code> git remote add $name $URL</code>url
To do this, first you need to add the main repository as a remote. Type:
 
<code> git remote add $name $URL</code>
 
Replace $name with whatever you want to label the remote, and $url with the github url for the main repository.
When you do the "git remote -v" command, you should see that you now have two sets of fetch/push listings. To get an updated version of the main repository, you can type:
 
<code> git fetch $name-of-main
git merge
</code>
 
To update your remote personal repository, you can type:
 
<code> git push origin master</code>
 
To do this, firstIf you needtry to addupdate the main repository as a remote.directly, by Typetyping:
 
git push $name master
 
You should get an error, as you don't have push access to the main repository.
 
That's it! You can add as many remotes as you'd like, although for the most part people stick to one or two.
Anonymous user