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 91:
This is a special trick that we do during the Website editing with git exercise, using Github Pages. It demonstrates that when the merge happens, it can programmatically cause a different event; this is often called ''hooks''.
 
== Advanced/Optional: Merge ConflictsCommands ==
 
(This section is in progress.)
 
=== Setting multiple remotes ===
If you're finished with the above and eager to learn more, you can also explore the world of merge conflicts. A merge conflict happens when two different commits change the same part of a file.
 
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:
For instance, let's say
 
<code>git remote -v</code>
 
You should see something like this:
<code>origin url/$yourusername/$repositoryname (fetch)</code>
<code>origin url/$yourusername/$repositoryname (push)</code>
 
Origin is the default name for your remote repository. The URLs should correspond to the URLs you used in the "git clone" command above. There are separate listings for "fetch" and "push" because [??????].
 
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?
 
To do this, first you need to add the main repository as a remote. Type:
 
<code> git remote add $name $URL</code>
 
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>
 
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