Skip to content
A set of exercises for deliberate Git Practice
Shell PowerShell Python
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
3-way-merge Consistently use dashes in utils function names May 25, 2020
advanced-rebase-interactive Consistently use dashes in utils function names May 25, 2020
amend Consistently use dashes in utils function names May 25, 2020
bad-commit Consistently use dashes in utils function names May 25, 2020
basic-branching Merge pull request #235 from praqma-training/git-katas-issue-59 Apr 15, 2020
basic-cleaning Consistently use dashes in utils function names May 25, 2020
basic-commits Consistently use dashes in utils function names May 25, 2020
basic-revert Simplify basic revert Apr 29, 2020
basic-staging Merge pull request #235 from praqma-training/git-katas-issue-59 Apr 15, 2020
basic-stashing Merge pull request #235 from praqma-training/git-katas-issue-59 Apr 15, 2020
bisect Consistently use dashes in utils function names May 25, 2020
commit-on-wrong-branch-2 Consistently use dashes in utils function names May 25, 2020
commit-on-wrong-branch Consistently use dashes in utils function names May 25, 2020
configure-git Fixed language and content for config-git May 25, 2020
detached-head Consistently use dashes in utils function names May 25, 2020
docs Set theme jekyll-theme-midnight Oct 11, 2019
ff-merge Consistently use dashes in utils function names May 25, 2020
git-attributes Consistently use dashes in utils function names May 25, 2020
git-tag Consistently use dashes in utils function names May 25, 2020
ignore Consistently use dashes in utils function names May 25, 2020
images Add clone step to README Gif Oct 21, 2019
investigation Consistently use dashes in utils function names May 25, 2020
master-based-workflow Add fake author in master-based-workflow exercise May 18, 2020
merge-conflict Consistently use dashes in utils function names May 25, 2020
merge-driver
merge-mergesort Consistently use dashes in utils function names May 25, 2020
objects Fixed numbering, so that it now increments both in shell and in markdown Aug 7, 2019
pre-push Add +x rights to pre-push setup.sh May 25, 2020
rebase-branch Consistently use dashes in utils function names May 25, 2020
rebase-exec Consistently use dashes in utils function names May 25, 2020
rebase-interactive-autosquash Consistently use dashes in utils function names May 25, 2020
reorder-the-history Consistently use dashes in utils function names May 25, 2020
reset Consistently use dashes in utils function names May 25, 2020
reverted-merge Consistently use dashes in utils function names May 25, 2020
save-my-commit Consistently use dashes in utils function names May 25, 2020
squashing Consistently use dashes in utils function names May 25, 2020
submodules changed how shell script could be sourced in katas Apr 9, 2020
utils Consistently use dashes in utils function names May 25, 2020
.gitattributes Added .gitattributes to make line endings consistent. Sep 20, 2019
.gitignore Merge branch 'master' into git_attributes Oct 9, 2019
LICENSE.txt Add license Feb 10, 2017
Overview.md Use explicit numbering Feb 10, 2020
README.md clearing the description to be precise Apr 8, 2020
SHELL-BASICS.md Mention `less` in SHELL-BASICS.md Nov 27, 2019
test.ps1 Add test powershell close #161 Nov 9, 2018
test.sh Add bash test script Nov 9, 2018

README.md

maintainer
randomsort

Git Katas

Quick Start

In the Cloud

Open in Cloud Shell

On Your Local Machine

Quick Start

  • Clone this repository
  • Go into the folder you want to solve an exercise in
  • Run the setup.sh script
  • Consult the README.md in that folder to get a description of the exercise

Purpose of Git Katas

This repository is a collection of Git exercises. The concept is stolen without shame from Schauderhaft.de. Unfortunately, they have not maintained the system - and we need more good Git exercises.

The exercises are designed for use when we are teaching Git courses. You should be able to use them as self-contained exercises that will allow you to keep your Git skills sharp.

Exercises starting with basic are entry-level - other exercises vary greatly in difficulty.

To get an overview of the exercises in here look in Overview.md.

Feel free to use these exercises, that's why they're public!

Suggested Learning Path

If you are coming to this repository for some basic Git knowledge, we recommend going through the exercises in the following order. This is the order that Jan Krag at Praqma teaches Git and might change over time. There are more exercises than this, but these should take you through everything you need to be able to use Git effectively in your day to day life.

See Overview.md for a more complete list and suggested order.

Contributing

If you miss exercises or find errors in any of them, feel free to improve them and make a pull request.

You can also make an issue so we notice an opportunity to improve!

Thank you!

Cheatsheet

A collection of useful commands to use throughout the exercises:

# Initializing an empty git repository.
git init            # Initialize an empty git repository under current directory.

# Cloning a repository
git clone https://github.com/praqma-training/git-katas.git      # Clone this repository to your current working directory

# Git (user and repo level) configurations
git config --local user.name "Repo-level Username"          # For setting a local git repo level user name.
git config --local user.email "Repo-level.Email@Example.com" # For setting a local git repo level user email.
                                                            # --global -> User level git config stored in <user-home>/.gitconfig for e.g. ~/.gitconfig
                                                            # --local -> repo level config stored in repo's main dir under .git/config


# See local changes
git status                  # Show the working tree status
git diff                    # Show changes current working directory (not yet staged)
git diff --cached           # Show changes currently staged for commit

# Add files to staging (before a commit)
git add myfile.txt          # Add myfile.txt to stage
git add .                   # Add entire working directory to stage

# Make a commit
git commit                              # Make a new commit with the changes in your staging area. This will open an editor for a commit message.
git commit -m "I love documentation"    # Make a new commit with a commit message from the command line
git commit -a                           # Make a new commit and automatically "add" changes from all known files
git commit -am "I still do!"            # A combination of the above
git commit --amend                      # Re-do the commit message of the previous commit (don't do this after pushing!)
                                        #   We _never_ change "public history"
git reset <file>                        # Unstage a staged file leaving in working directory without losing any changes.
git reset --soft [commit_hash]          # resets the current branch to <commit>. Does not touch the staging area or the working tree at all. 
                                        # --hard mode would discard all changes.

# Configuring a different editor
## Avoid Vim but stay in terminal:
- `git config --global core.editor nano`

## For Windows:
- Use Notepad:
`git config --global core.editor notepad`

- or for instance Notepad++:
`git config --global core.editor "'C:/Program Files/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin"`


# See history
git log             # Show commit logs
git log --oneline   # Formats commits to a single line (shorthand for --pretty=oneline  --abbrev-commit )
git log --graph     # Show a graph commits and branches
git log --pretty=fuller     # To see commit log details with author and committer details, if any different.
git log --follow <file>     # List the history of a file beyond renames
git log branch2..branch1    # Show commits reachable from branch1 but not from branch2

# Deferring
git stash                               # Stash (store temporarily) changes in working branch and enable checkingout a new branch
git stash list                          # List stored stashes.
git stash apply <stash>                 # Apply given <stash>, or if none given the latest from stash list.


# Working with Branches
git branch my-branch       # Create a new branch called my-branch
git checkout my-branch     # Checkout ("Switch" to work on) my-branch
git checkout -b my-branch  # Create a new branch called my-branch AND switch to it
git branch -d my-branch    # Delete branch my-branch that has been merged with master
git branch -D my-branch    # Forcefully delete a branch my-branch that hasn't been merged to master

# Merging
git merge master         # Merge the master branch into your currently checked out branch.
git rebase master        # Rebase current branch on top of master branch

# Working with Remotes
git remote              # Show your current remotes
git remote -v           # Show your current remotes and their URLs
git push                # Publish your commits to the upstream master of your currently checked out branch
git push -u origin my-branch  # Push newly created branch to remote repo setting up to track remote branch from origin. 
                              # No need to specify remote branch name, for e.g., when doing a 'git pull' on that branch.
git pull                # Pull changes from the remote to your currently checked out branch

# Re/moving files under version control
git rm <path/to/the/file>                 # remove file and stage the change to be committed.
git mv <source/file> <destination/file>   # move/rename file and stage the change to be committed.  

# Aliases - it's possible to make aliases of frequently used commands
#   This is often done to make a command shorter, or to add default flags

# Adding a shorthand "co" for "checkout"
git config --global alias.co "checkout"
# Usage:
git co      # Does a "git checkout"

## Logging
git log --graph --oneline --all # Show a nice graph of the previous commits
## Adding an alias called "lol" (log oneline..) that shows the above
git config --global alias.lol "log --graph --oneline --all"
## Using the alias
git lol     # Does a "git log --graph --oneline --all"

Testing

There is a very small test that you can run in powershell or bash. It is contained in the scripts test.sh and test.ps1.

You can’t perform that action at this time.