Edit .gitignore file through terminal
Setup
Download the CSV file
wetlands_seasonal_bird_diversity.csvfrom our shared drive.In the workbench 1 server, inside your
EDS-220/eds220-in-class/directory, create a new directory calleddata.Using the file navigation panel, upload the
wetlands_seasonal_bird_diversity.csvfile to thedatadirectory.
In the terminal
- Verify you are in the
eds220-in-class/directory by usingpwd. Your output should look like this:
/Users/your-username/MEDS/EDS-220/eds220-in-class- Run
git status. At the end of the output you’ll see:
Untracked files:
(use "git add <file>..." to include in what will be committed)
data/This means git has detected that the data directory exists but it is not yet tracking changes in it. We are in charge of deciding whether we want to track changes in it or not!
- Run
lsto see the files in the directory. Your output will look like this, notice the.gitignorefile is not listed:
README.md week1-lesson1-python-review.ipynb
data week1-lesson3-pandas-subsetting.ipynb- Run
ls -ato see all files in the directory, including hidden files (those that start with a period.). At this point, your output will look like this:
. README.md
.. data
.git week1-lesson1-python-review.ipynb
.gitignore week1-lesson3-pandas-subsetting.ipynb
.ipynb_checkpointsRun
nano .gitignore. This will open the.gitignorefile in thenanoeditor.Add the
datafolder to the.gitignorefile by adding this text at the top of the file:
# Ignore the 'data' directory
data/Once you have made your changes, save the file:
- In
nano, pressCTRL + O(the letter O, not zero) to save. - Press
Enterto confirm the file name (.gitignore).
- In
Exit the editor by pressing
CTRL + X.Run
less .gitignoreto scroll through the.gitignorefile and verify the changes are there:- Use the arrow keys or
Page Up/Page Downto scroll through the file. - Press
qto exit.
- Use the arrow keys or
Run
git statusand check the output. Thedatadirectory will no longer be listed! You will see your.gitignorehaving changes ready for commit.Commit and push your changes to the
.gitignore.
