Git
Summary
Introduction to Git
Git is a version control system designed to help track changes in files and facilitate collaboration. It provides:
- History: Keeps track of changes made to files.
- Collaboration: Enables teams to work together effectively.
Ways to Use Git
- Command Line: The most powerful and direct way to use Git.
- Integrated Development Environment (IDE): Many IDEs have built-in Git support (e.g., VSCode).
- Graphical User Interface (GUI): Tools like GitKraken simplify Git visually.
Work Process Detail
- Git Tutorial
How to Download and Install Git Bash
Git Bash is a command-line tool for Windows that allows you to use Git commands and Linux-like features. Follow these steps to download and install Git Bash:
1. Download Git
- Go to the official Git website: git-scm.com.
- Click on the Download button. The site will automatically detect your operating system (Windows, macOS, or Linux).
2. Install Git on Windows
- Once the file is downloaded, locate it (e.g.,
Git-x.x.x-x64.exe
) and double-click to open the installer.
- Follow the installation wizard steps:
- Select Destination Location: Choose where to install Git or leave it as the default.
- Select Components: Ensure "Git Bash Here" and "Git GUI Here" are selected.
- Default Editor: Choose an editor for Git (e.g., VSCode or Nano).
- Adjust PATH Environment: Select "Use Git from the command line and also from third-party software" (recommended).
- HTTPS Settings: Leave the default option (Use OpenSSL).
- Line Ending Conversions: Use the default option ("Checkout Windows-style, commit Unix-style line endings").
- Terminal Emulator: Select "Use MinTTY" (default terminal for Git Bash).
- Continue with the default options for the remaining steps unless you need custom configurations.
- Click Install and wait for the installation to complete.
- Once the file is downloaded, locate it (e.g.,
3. Launch Git Bash
- After the installation is complete, click Finish.
- Open Git Bash:
- Use the Start Menu to search for "Git Bash."
- Alternatively, right-click anywhere on your desktop or in a folder, and select "Git Bash Here."
4. Verify Installation
- Open Git Bash and type:
This will display the installed Git version, confirming a successful installation.git --version
- Open Git Bash and type:
Setting Up Git
Configure Git for the First Time:
- Set your name:
git config --global user.name "Your Name"
- Set your email:
git config --global user.email "your.email@example.com"
- Configure a default editor (e.g., VSCode):
git config --global core.editor "code --wait"
- Enable line endings for compatibility:
git config --global core.autocrlf true
Check Git Configuration:
- View Git settings:
git config --list
- For help:
git --help git -h
Basic Git Commands and Workflow
Initialize a Repository
- Create and navigate to a directory:
mkdir project_name cd project_name
- Initialize Git in the directory:
git init
Workflow Steps
- Edit files as needed.
- Check the current status:
git status
- Add files to the staging area:
To add all changes:git add file_name
git add .
- Commit the changes:
git commit -m "Your commit message"
Understanding Git Workflow

- Files: The working directory contains files you are editing.
- Index: Staging area where changes are prepared for a commit.
- Repository: Where the final snapshot of your project is stored after a commit.
Removing Files in Git
- Delete a file from your working directory:
rm file_name
- Stage the removal:
git add file_name
- Commit the removal:
git commit -m "Removed file_name"
- Alternatively, remove and stage in one step:
git rm file_name
Visual Representation of Commit Sizes
- Small, incremental commits are preferred over large commits. They make tracking and debugging easier.
Learning Outcome
Learning Git workflow is super impotent for team work and project development, and knowing how to use it will help the maker community to level up their development.