While having a repo for yourself is nice for version control, how do you add to somebody else's work? There are some pretty neat ways of handling this, but right now, we'll go through one of the simplest.
Commands you'll learn#
In this tutorial you'll be using the following commands:
* git pull
: Get changes from the repo's GitHub page (or another 'remote') into your local folder
* git push
: Sync your commits back to your repo's GitHub page (or another 'remote')
Adding to It#
-
Learner C: Create a new repo called 'soup', and add Learner A and Learner B as collaborators.
-
Learner C: Add a file
ingredients.md
. Populate it with a short list of ingredients that would make a medieval witch scratch her head. Commit your list. Add a few more ingredients (or delete some!). Commit again. Push your commits withgit push origin master
. -
Learners A and B: Get the necessary URL from Learner C, then clone Learner C's 'soup' repo (
git clone https://github.com/learnerc/soup.git
, where you need to substitute the correct URL), and go into the repo's folder:cd soup/
-
Learners A and B: Do
git log
to see what Learner C has been up to so far. -
Learner C: Add another ingredient to your file, commit and push again.
-
Learner A and B: As Learner C has added more stuff, you need to update your local clone of their repository! To do this, call
git pull
. Check what just happened withgit log
. Do you see the new commit that Learner A only added to their repo after you first cloned it? -
Learner A: In the repo's folder, create a new file called
spices.md
. In that file, list some fantasmorgacically hot spices. Do agit status
. What does have git to say about your new file so far? -
Learner A: Do
git add spices.md
to tell git that it should prepare for a snapshot of your changes to that file. (Just like in the first tutorial.) Checkgit status
. -
Learner A: Do
git commit -m 'blablabla'
to create a new snapshot (commit) of the repo as you have it now, which includes your new file now! You should probably make the commit message more meaningful than 'blablabla'. Then, push your changes:git push origin master
, to synchronize your local commits with your repo on GitHub (your 'remote'). -
Learner B and C: Pull the changes that Learner A made, and show Learner A that you now have the spice list. Also show Learner A your
git log
. Learner A's commit is there! (Great success.)
Here is the next tutorial.
Talking of spicy food, here is YouTube channel of a Dutchman eating chili peppers while interviewing people.