Skip to content
This repository has been archived by the owner on Jan 8, 2025. It is now read-only.

Latest commit

 

History

History
65 lines (51 loc) · 3.43 KB

git.md

File metadata and controls

65 lines (51 loc) · 3.43 KB

Git

Installation

  1. Install Git
    1. Destination location: default is fine
    2. Components: defaults are fine
    3. Default editor: "Use VisualStudioCode as Git's default editor"
    4. Start Menu Folder: default is fine
    5. Adjusting your PATH: "Use Git from the Windows Command Prompt" recommended
    6. HTTPS - SSL/TLS library: "Use the OpenSSL library" recommended
    7. Line-ending conversions: "Checkout as-is, commit as-is"
    8. Terminal emulator for Git Bash: "Use Windows' default console window" recommended
    9. Extra options: recommended to select all
      1. Enable file system caching
      2. Enable Git Credential Manager
      3. Enable symbolic links
  2. Generate an SSH key
    1. guide
  3. Configure Git
    1. git config --global user.name <your name>
    2. git config --global user.email <your email>
      1. Use the same e-mail address associated with your GitHub account
    3. git config --global gui.encoding utf-8
    4. git config --global core.autocrlf false
    5. git config --global core.ignorecase false
    6. git config --global core.safecrlf false
    7. git config --global pull.rebase true
    8. git config --global branch.autosetuprebase always
  4. GUIs (optional)
    1. (Windows) TortoiseGit
    2. (Windows) Git Extensions
    3. (Mac, Windows) Sourcetree

Git Gui

Git comes with a GUI in addition to the CLI. In Windows, you should be able to right-click a folder and choose "Git GUI Here" from the context menu to open it. In any OS, you can type git gui from the command line.

You can configure the tab size in Git Gui:

git config --global gui.tabsize 4

Visual Studio Code

VS Code has built-in support for Git that is very useful.

⛔ NEVER click the "Synchronize Changes" icon at the left of VS Code's bottom status bar. This will sometimes create completely unnecessary merge commits.

Git basics

Git stores the history of your code and simplifies collaboration, experimentation, and ensuring that you always have a stable copy of your code.

  1. History: when you edit files, Git notices they have changed. It does not automatically track every change. When you have made a set of changes that you want Git to track, you commit those changes. Git's history is a tree of commits.
  2. Branches: a new repository starts with a default branch named "master". We want to ensure master has completed, tested code, so if you start work on a new feature you create a new branch. When you create a new branch you get a copy of everything in master at the time you create the branch. Changes can continue happening in master while you make changes in your branch, but you will not automatically get those changes. When work in your branch is completed and tested it will be incorporated into master.
  3. Rebasing: rebasing is the cleanest way of copying changes from one branch to another. When you create a new branch from master and need to copy new updates from master to your branch, you will rebase.

Learning resources

  1. Git book (chapters 1-3, 5, 6-8)
  2. Feature branch workflow
  3. Rebasing
  4. Rebase workflow