Sometimes, you want to keep a files in your repo's directory local, and not share it. Git has an app, errm, file, for that!
Commands you'll learn#
In this tutorial you'll be using the following commands:
* .gitignore
: A file that lists files (or file and folder name patterns) that should be excluded from commits.
Keeping It Special#
-
Learner B: You would like to add an ingredient to the soup which should not be mentioned to the public, or your partners. Create a file
sauce.secret
, and name your secret ingredient in it. Do agit status
. What does git think about your new file? -
Learner B: Create a
.gitignore
file, and add a line saying*.secret
to it. Dogit status
again. What has changed? Your secret file should no longer appear there. -
Learner B: Tell git that you want it to include the
.gitignore
file in your commit:git add .gitignore
. Then commit and push your changes. -
Learner A and C: Get the changes that Learner B just made: Say
git pull
. List all files (includen hidden ones) withls -a
. Did you receive the.gitignore
? What about thesauce.secret
? Which of those two files appears in the repo on GitHub? Also have a look at yourgit log
.
Here is the next tutorial.