forked from eficode-academy/git-katas
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bb52781
commit 6c8746e
Showing
4 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Git kata: Aliases | ||
|
||
While working, we tend to write a lot of commands. This can get tedious, especially when the commands are rather long. Git allows you to create an alias for commands, dramatically shortening the time spent typing them. | ||
|
||
Aliases are stored in your git config and can thus be global or local. Global config is tied to your user, while local config lives inside a specific repository. | ||
|
||
## Setup | ||
|
||
1. Run `source setup.sh` (or `.\setup.ps1` in PowerShell) | ||
|
||
## The task | ||
|
||
1. View your config by running `git config --list` | ||
2. Add a new global alias\ | ||
`git config --global alias.lol 'log --oneline --graph --all'`\ | ||
This allows you to call `git lol` as an alternative to `git log --oneline --graph --all` | ||
3. Run your alias `git lol` | ||
4. Run the full command `git log --oneline --graph --all`\ | ||
Are there any difference in the output? | ||
5. Create another alias, this time local, that lists commits where you are the author\ | ||
`git config --local alias.lome "log --author=\"$(git config --get user.name)\""` | ||
6. Run your alias `git lome`\ | ||
What does it show? | ||
7. View your git config and its sources by running `git config --list --show-origin`\ | ||
Can you find your alias configurations? | ||
8. Try running `git lome` in a different git repository\ | ||
Does it work? | ||
9. Remove your `git lol` alias by running `git config --unset alias.lol` | ||
|
||
## Useful commands | ||
|
||
- `git config --list` | ||
- `git config --list --show-origin` | ||
- `git config get <configuration>` | ||
- `git config --unset <configuration>` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
. ..\utils\make-exercise-repo.ps1 | ||
|
||
Set-Content -Value "dummy" -Path dummy.txt | ||
|
||
git add dummy.txt | ||
git commit -m "dummy commit" | ||
Set-Content -Value "dummy2" -Path dummy.txt | ||
git add dummy.txt | ||
git commit -m "adding more content to dummy.txt" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
|
||
# Include utils | ||
source ../utils/utils.sh | ||
|
||
kata="$(basename $(pwd))" | ||
make-exercise-repo | ||
|
||
echo "dummy" > dummy.txt | ||
git add dummy.txt | ||
git commit -m "dummy commit" | ||
echo "dummy2" > dummy.txt | ||
git add dummy.txt | ||
git commit -m "adding more content to dummy.txt" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters