Skip to content

Git Fundamentals

vinhtbkit edited this page Nov 21, 2023 · 1 revision

Git

  • Target: the trainee will have a solid understanding on how Git works, how to do some basic commands with Git and practice on the Git flows
  • Expected Duration: 40 hours of training and working on exercises

Qualification Criteria

  • Trainees need to prove their understanding for Git basics
  • Trainees need to show the Git skills, especially using CLI
    • Know how to use the CLI fluently, not only basic usages but also some advanced use cases
  • Trainees know how to follow the Gitflow workflow
    • Provide a scenario, knows what branches and process to work on
    • Knows how to work with Pull Requests and resolve conflicts
  • Trainees know how to use at least one Git tool (Github, Bitbucket, Gitlab...)

Git Overview

Trainees need to get the basics of the following knowledge:

REQUIRED

  • What is Git
  • Why use Git
  • Git alternatives

Git basics

Trainees are free to select any SCM to practice with this training: Github, Gitlab, Bitbucket...

REQUIRED

  • Repository
  • Commit
    • Git commit best practices
  • Remote
  • Branch
    • HEAD
  • Git configuration
  • Setup SSH public key
  • .gitignore
  • Undo changes, revert a mistake
  • Basic commands: clone, fetch, checkout, commit, log, reset, add, branch, merge, push, pull, remote, stash

References:

Git flows

REQUIRED

  • Gitflow workflows
    • Branching model
    • Pull requests
  • Resolving conflicts

References:

Git in-depth

REQUIRED

  • Forking
  • Rebasing
  • Cherry pick

OPTIONAL

  • Blame
  • Bisect
  • Submodules
  • Git hooks

Github

  • Find your Github username
  • Config SSH for Github account
  • Create repository. Clone with HTTPs and SSH
    • OPTIONAL Using personal access token
  • Using features:
    • Create, edit files on browser
    • Add collaborators to project
    • Checking branches and commit history
    • Working with Pull requests:
      • Create, comments, merge, decline
      • Draft PR, suggest code changes

Bitbucket

Gitlab

Quizzes

  1. How the commits are created and travel from local to remote?
  2. Which files are often ignored from Git?
  3. Explain git reset with --hard and --soft?
  4. Differences between pull, merge and rebase?
  5. What are untracked files and how to track/remove them?
  6. How can I switch between different branches without losing the current work, but not creating bad commits?
  7. How can I use different Git accounts in different projects?
  8. What are conflicts? In which cases are conflicts going to happen?
  9. When you are resolving a conflict, how do you abort the progress and keep your work the same before resolving?
  10. Why do we need hotfix and release branches in Gitflow?

Assignments

The obvious Gitflow
In this project, trainees are required to create a project from scratch, add a git project and try to resolve some typical issues working with Git.

  • Pre-requisites:
    • A Github account
  • Requirements:
    • Fork the source code repository at github:bkit-assignment-git-1 and checkout locally. Name this remote: forked
    • Create a new feature branch, and update the changelog.md with your work ( using the existing formats)
    • Create a Pull Request (PR) to main branch of github:bkit-assignment-git-1, and add your trainer for review.
    • Add another remote (named base) to the project, which points to the github:bkit-assignment-git-1 repository
    • (Simulation: another contributor made some changes upstream) Switch to your feature branch, and merge the branch hotfix/sudden-change in base remote
    • Now expects the PR to have conflicts, now you resolve it using CLI
  • Acceptance Criteria
    • Trainee needs to use the CLI to operate with Git, except for working with Pull Requests
    • Document the list of commands used for each task above
    • The output don't contain any unnecessary Git commits
    • Follow the Gitflow workflow
    • If the trainers aren't doing pair coding, the trainer should provide a list of commands step-by-step