Skip to content

Instantly share code, notes, and snippets.

@TizioFittizio
Last active July 1, 2024 08:24
Show Gist options
  • Save TizioFittizio/36fd4512346cd5ca16ecab8974c16f91 to your computer and use it in GitHub Desktop.
Save TizioFittizio/36fd4512346cd5ca16ecab8974c16f91 to your computer and use it in GitHub Desktop.
Git Exercises

Exercises

  • Basics

    • Init a repository
    • Track and stage new files
    • Execute a commit
    • Clone a repository
    • Know state of a file (untracked, unmodified, modified, staged)
    • Obtain current status of files
    • Get a short version of status
    • Know when a file can be both staged and unstaged
    • Get exactly file differences between current files and last commit
    • Get exactly file differences between staged files and last commit
    • Commit files skipping staging area
    • Remove a file (staging the removal of a file)
    • Remove a file forcing and without deleting it
    • Redoing/modify last commit
    • Unstage a file
    • Undoing changes in a file
    • Know what sha-1 is
  • Ignoring

    • Commit a gitignore
    • Commit an empty folder
    • Comment rows in gitignore
    • Ignore all files except folders and files in folders
    • Ignore all files with .txt format
    • Ignore all files with .txt format except file important.txt
    • Ignore a subfolder in a folder
    • Ignore all files
    • Ignore all files in a folder
    • Ignore all files that ends with a number
    • Ignore a folder regardeless its level in path
    • Ignore all files and subfolders in a folder
  • Tagging

    • List tags
    • List tags starting with v1
    • Know difference between lightweight and annotated tags
    • Create an annotated tag
    • Create a lightweight tag
    • Tag a commit in the past
    • Push tags to a remote
    • Remove a tag from local repository
    • Remove a tag from a remote
    • Move to a commit by a tag
  • Branching

    • Create a new branch
    • Create and switch a branch at the same time
    • Know what HEAD is
    • Show where branch pointers are pointing
    • Switch branches
    • Merge a branch
    • Know what fast-forward merge strategy is
    • Know what recursive merge strategy is
    • How solve conflicts during merge
    • Know how to configure a mergetool
    • Open mergetool
    • Delete a branch
    • Get a list of branches
    • Get a list of branches with last commit
    • Get a list of branches that has not been merged to the current branch
    • Get a list of branches that has not been merged of another branch
  • Rebasing

    • Know what is the difference between merging and rebasing
    • Rebase changes of a branch to a different branch
    • Rebase changes of a branch (with patches of different branchs) to a different branch
    • Reabse to a different branch without checkout
    • Know what are the perils of rebasing
    • Rebase changes of a remote branch to a different branch
    • Know what cherry-picking is
  • Get history

    • Get commit history
    • Get commit history of different branch
    • Get commit history of all branches
    • Get commit history of a limited commits number
    • Get commit history with differences
    • Get summarized commit history
    • Get commit history with only one line per commit
    • Know difference between author and committer
    • Get commit history
    • Get commit history with graph
    • Get commit history of the last week
    • Get commit history after the start of the current month
    • Get commit history with git pickaxe option
    • Get commit history regarding only a single file
    • Get commit history regarding only a single folder
    • Get commit history of commits containing a word
    • Get commit history of commits of an author
    • Get commit history of commits of a committer
    • Get commit history without merge commits
    • Get commit with abbreviated hashes
    • Get N commit before HEAD
    • Get commit parent of a commit
    • Get all parents commit of a commit
    • Get grandparent commit of a commit
    • Get N parent commit of a commit
    • Get all parents commit of a grandparent commit of a commit
    • Get commits that has not been merged yet in a branch
    • Get all commits in a branch A that aren't in a branch B
    • Get all commits in branch A that you can push in a remote branch remote/A
    • Get all commits not merged from branch A to HEAD without write "HEAD"
    • Get all commits that are reachable from branch A, branch B but not branch C
    • Get commits history without commits of a branch
    • Get all commits reachable by two references but not by both (showing who can reach who)
  • Edit history

    • Change last commit message
    • Change last commit edits
    • Change last commit without inputting message
    • Change last 3 commits message
    • Change last third commit message
    • Change all commit messages from the start
    • Change order of commits
    • Merge 2 commits in one commit
    • Split a commit in two different commits
    • Merge 2 commits in one commit keeping only the message of the first commit
  • Remotes

    • Know what is a remote
    • Get a list of remotes
    • Get a list of remotes urls
    • Add a remote
    • Fetch from a remote
    • Pull from a remote
    • Know what a tracking branch is
    • Know what a upstream branch is
    • Push to a remote
    • Create a tracking branch with a different name
    • Setup a local branch to become a tracking branch
    • Change the upstream branch of a branch
    • Get a list of all branches with tracking and upstream informations
    • Delete a remote branch
    • Get informations of a remote
    • Rename a remote
    • Remove a remote
  • Stashing

    • Stash edits (in multiple ways)
    • Get a list of stashes
    • Apply a stash
    • Apply a stash that is not the most recent
    • Apply a stash with staged changes
    • Remove a stash (in multiple ways)
    • Adding a stash to the index
    • Create a stash with untracked files
    • Create a stash with ignored by default files
    • Create a branch from a stash
    • Simply remove existing edits
    • Remove existing edits along with folders that would become empty
    • Remove existing edits without the -f argument
    • Show what happens if you would remove existing edits
    • Remove existing edits in multiple git submodules
  • Online

    • Know local transfer protocol, Pros and Cons
    • Know http protocol, smart and dumb, Pros and Cons
    • Know ssh protocol, Pros and Cons
    • Know git protocol, Port, Pros and Cons
    • Create a bare repository
    • How to generate ssh keys (not necessarily git related but useful)
    • Know what centralized workflow is
    • Know what integration manager workflow is
    • Know what dictator and lieutenants workflow is
    • Know the general rules for a commit message
    • Know what a repository fork is
  • Config

    • List all global configurations
    • Get a global configuration
    • Set a global configuration
    • Know what aliases are
    • Setup an alias
    • Configure a credential helper
  • Signing

    • Know what gpg is
    • Generate a personal key with gpg
    • Setup git to use key to sign commits and tags
    • Use a private key to sign a tag
    • Verify a signed tag
    • Use a private key to sign a commit
    • Show tags and commits signatures in git log
    • Show tags and commits signatures in git log in a pretty format
    • Execute a git merge verifying a signature
    • Execute a git pull verifying a signature
    • Execute a merge and sign the commit merge
    • Know GPG pros and cons
  • Searching

    • Find a string in the codebase
    • Find a matching regexp in the codebase
    • Find a string in the codebase with relative file line number
    • Find which files contain a string in the codebase
    • Find how many times a file contains a string
    • Show the wrapping class/function/module of a string in the codebase
    • Find a line in the codebase where two different strings appear (no regexp)
    • Find a string in the codebase and split output results
    • Find what commits changed/created/removed a string
    • Find what commits changed/created/removed a regexp match
    • Show the history of a class/function/module
  • Tools

    • Know what reflog is
    • Know how to include reflog information in git log
  • Miscellaneous

    • Setup rerere
    • Generate a build number
    • Zip an archive
    • Obtain a shortlog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment