Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Introduction to Git!
You have completed Introduction to Git!
Preview
Before you can "push" commits to another repository, you need to add it as a remote repo.
Update
Add to myclone/medals.html:
<div>
<a href="gold.html">Gold medals</a>
</div>
<div>
<a href="silver.html">Silver medals</a>
</div>
- Then stage the changes:
git add medals.html, and commit them:git commit -m "Add links"- That commit now appears in our history for the
myclonerepository.
- That commit now appears in our history for the
- But this commit does not appear in the
medalsrepository. - Although we were able to run
git pullin themyclonerepository to pull in commits from themedalsrepository, we can't pull frommyclonetomedalsyet. - When we cloned the
medalsrepository to themyclonerepository,medalswas automatically set up as a remote repo onmyclone.- But the reverse isn't true. In fact, we can try running
git remotefrom themedalsrepo, and we won't see any remote repos at all.
- But the reverse isn't true. In fact, we can try running
- So we're going to need to add
mycloneas a remote on themedalsrepo.- We can do this with the
git remote addsubcommand. -
git remote addtakes two arguments: - The first is the name we want to give the remote repo. We can use any name we want, but generally, it should be all lowercase. We'll use the name
myclonefor this remote. - The second argument will usually be the URL of the remote repository.
- But since this "remote" repo is just another directory on our local computer, we'll give it the path to that directory instead:
../myclone
- But since this "remote" repo is just another directory on our local computer, we'll give it the path to that directory instead:
- We can do this with the
git remote add myclone ../myclone
- Now let's try running
git remoteagain. This time, we'll see a remote repo with the name we specified,myclone. - For this first-time running
git pull, we need to provide two arguments:- The remote repo we're pulling from:
myclone - The "branch" we want to pull:
main| UPDATE - Renaming the default branch frommastertomain. - By default, Git repositories start with only one branch, named
main. - Because we haven't created any other branches, our work in the
myclonerepo will be on themainbranch there, as well.
- The remote repo we're pulling from:
git pull myclone main
- That command will pull our new commit from the
mycloneremote repo into themedalsrepo.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
Now let's take a look at what's changed,
git diff.
0:00
We realize that there was
no link to the gold.html or
0:03
the silver.html pages from the main page,
so we added links and saved the file.
0:06
Let's stage the changes,
git add medals.html,
0:12
and now let's commit them,
git commit -m "Add links".
0:18
That commit now appears in our history for
the myclone repository.
0:25
If we run git log,
we'll see the add links commit at the top.
0:28
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up