Given a directory structure that looks like:
results/data
results/plots
How would you ignore only results/plots
and not results/data
?
How would you ignore all .dat
files in your root directory except for
final.dat
?
Hint: Find out what !
(the exclamation point operator) does
Given a directory structure that looks similar to the earlier Nested Files exercise, but with a slightly different directory structure:
results/data
results/images
results/plots
results/analysis
How would you ignore all of the contents in the results folder, but not results/data
?
Hint: think a bit about how you created an exception with the !
operator
before.
Assuming you have an empty .gitignore file, and given a directory structure that looks like:
results/data/position/gps/a.dat
results/data/position/gps/b.dat
results/data/position/gps/c.dat
results/data/position/gps/info.txt
results/plots
What’s the shortest .gitignore
rule you could write to ignore all .dat
files in result/data/position/gps
? Do not ignore the info.txt
.
Let us assume you have many .dat
files in different subdirectories of your repository.
For example, you might have:
results/a.dat
data/experiment_1/b.dat
data/experiment_2/c.dat
data/experiment_2/variation_1/d.dat
How do you ignore all the .dat
files, without explicitly listing the names of the corresponding folders?
Given a .gitignore
file with the following contents:
*.dat
!*.dat
What will be the result?
You wrote a script that creates many intermediate log-files of the form log_01
, log_02
, log_03
, etc.
You want to keep them but you do not want to track them through git
.
Write one .gitignore
entry that excludes files of the form log_01
, log_02
, etc.
Test your “ignore pattern” by creating some dummy files of the form log_01
, etc.
You find that the file log_01
is very important after all, add it to the tracked files without changing the .gitignore
again.
Discuss with your neighbor what other types of files could reside in your directory that you do not want to track and thus would exclude via .gitignore
.
.gitconfig
The command git config
is used to set Git configuration values on a global or local project level which correspond to .gitconfig
text files.
Executing git config
like we did in setup will modify a configuration text file.
Here is an example global .gitconfig
file which we created from git config --global
:
[user]
email = Vlad Dracula
name = vlad@tran.sylvan.ia
[pull]
rebase = true
[credential]
helper = manager-core
helper = /usr/bin/git-credential-manager-core
credentialStore = gpg
[github]
user = vladDracula
But like .gitignore
they can be added at a project level for specific behavours such as in the example above where we are
telling git to use the rebase merge strategy instead of fast forward merge.