The git config - which we talked about earlier - command comes with three built in scope: --system, --global and --local The problem is that they are all outside the scope of what is being versions controlled.
[ ] Investigate (Google it - or dive straight into the manual) - which file is written to in each of the different scopes?
In order to have a git config file that can be shared among developers in the same project it need to be in the repo.
[ ] Create a new file in the root of the repository called .gitconfig (remember the dot that makes it hidden) like this:
Use the command line to create the file
```
touch $(git root)/.gitconfig
```
[ ] First create an alias co which will simply be shorthand for checkout
[ ] Second bring your root alias into the new shared .gitignore file. That is remove it from the --global location and bring it into the .gitignore file in the root of you repo.
HINTS
---
```shell
# Create a co shorthand alias for checkout
git config --file $(git root)/.gitconfig alias.co checkout
```
a) Open `~/.gitconfig` and find the `root` alias in there and cut'n'paste it into the `.gitignore` file using your editor
or
b) Do it from the command line:
```
# Redo the previous command in .gitignore
git config --file $(git root)/.gitconfig --add alias.root "rev-parse --show-toplevel"
# Remove it from the global location
git config --global --unset alias.root
```
---
Open the file you just created and see it in the editor - I often find that it's easier to open the config files and edit them directly in an editor.
[ ] What does the new alias co do?
[ ] Try to run it - do you think it will work?
git co
git root
....Hmmmm! WFT? 🔥
---
# IT DOESN'T WORK!
...yet!
---
Git config supports includes - so we can include the file in one of the three other levels; system, global and local.
But --system and --global scope files are related to machine and user scop and therefore not relative to the reach of the repo --local is not entirely off - it's in the .git folder in the repository. But it's not includede in teh scope that is version controlled - it's an internal control file. Meant to be used by git itself - not us. But the location - inside the repository root - suits us.
Only one single command is required to load the new file we just created in the repo:
git config --local include.path ../.gitconfig
[ ] Now try your aliases again:
git co
git root
Yeah! and then
[ ] Can you find and open the file, the command above just wrote to?
The
git config
- which we talked about earlier - command comes with three built in scope:--system
,--global
and--local
The problem is that they are all outside the scope of what is being versions controlled.[ ] Investigate (Google it - or dive straight into the manual) - which file is written to in each of the different scopes?
In order to have a git config file that can be shared among developers in the same project it need to be in the repo.
[ ] Create a new file in the root of the repository called
.gitconfig
(remember the dot that makes it hidden) like this:Use the command line to create the file
``` touch $(git root)/.gitconfig ```[ ] First create an alias
co
which will simply be shorthand forcheckout
[ ] Second bring your
root
alias into the new shared.gitignore
file. That is remove it from the--global
location and bring it into the.gitignore
file in the root of you repo.HINTS
--- ```shell # Create a co shorthand alias for checkout git config --file $(git root)/.gitconfig alias.co checkout ``` a) Open `~/.gitconfig` and find the `root` alias in there and cut'n'paste it into the `.gitignore` file using your editor or b) Do it from the command line: ``` # Redo the previous command in .gitignore git config --file $(git root)/.gitconfig --add alias.root "rev-parse --show-toplevel" # Remove it from the global location git config --global --unset alias.root ``` ---Open the file you just created and see it in the editor - I often find that it's easier to open the config files and edit them directly in an editor.
[ ] What does the new alias
co
do?[ ] Try to run it - do you think it will work?
....Hmmmm! WFT? 🔥
--- # IT DOESN'T WORK! ...yet! ---Git config supports
includes
- so we can include the file in one of the three other levels; system, global and local.But
--system
and--global
scope files are related to machine and user scop and therefore not relative to the reach of the repo--local
is not entirely off - it's in the.git
folder in the repository. But it's not includede in teh scope that is version controlled - it's an internal control file. Meant to be used by git itself - not us. But the location - inside the repository root - suits us.Only one single command is required to load the new file we just created in the repo:
[ ] Now try your aliases again:
Yeah! and then
[ ] Can you find and open the file, the command above just wrote to?