- Fork this repo by clicking Fork in the top-right corner. Awesome, now you know how to fork. All of the directions below are just other cool things you can do with Git & Github.
- Now that you have your own copy, go into the repo settings (gear icon) and rename your copy to
forking-practice
. - Clone your remote copy into your local IDE.
- Make a new directory in this repo named
subdir
- READ what your command line says back to you when you try to add/commit/push!
- Since we can't commit an empty directory,
cd
intosubdir
and create a file namedready.txt
. Go ahead and put some text in that file: it can be whatever you want. But hold on, don't commit yet. - Go back up one level to the top-level directory by doing
cd ..
and make a file namednotready.txt
. - Use
git status
to see that bothnotready.txt
andsubdir/
are in red (really,subdir/
in this case meanssubdir/notready.txt
). - While we typically use
git add .
to add everything to the stage, let's imagine thatsubdir/ready.txt
is ready to be committed, butnotready.txt
isn't. So trygit add subdir/ready.txt
to make sure that we add only that file to the stage, and NOTnotready.txt
. - Do
git status
again to confirm thatsubdir/ready.txt
is green, andnotready.txt
is red. - Go ahead and commit, then push!
- If you haven't already, reload your fork on GitHub. You should see your changes, except for
notready.txt
. - One last thing. You know how you can see the exact changes in commits by looking at them on Github? Here is an example. But what about local changes that haven't been committed yet: how do we know what we've done locally before we commit and push them to Github? After all, this would probably help us come up with a good commit message ("wait... what did I do since my last commit?"). To show you, go ahead and change some text in your
subdir/ready.txt
file: again, it can be whatever you want. Now in your terminal, typegit diff
to see what you've changed since your last commit. Pretty cool, eh? Go ahead and add/commit/push JUST that file again (notready.txt
is still not ready).
That's it, you're done!
To recap, we saw that:
- You can't commit an empty directory.
- You can add just some things to the stage, and thus not commit everything.
- You can see any new uncommitted local changes by doing
git diff
.