- Introduction
- Downloading Git
- Installing Git
- Configuring Git
- Init
- Clone
- Add
- Commit
- Remote
- Status
- Pull
- Push
- Git Style Guide
Git is a free and open-source distributed version control system designed to handle everything from small to very large projects with speed and efficiency. It allows multiple developers to work on the same project simultaneously, providing features such as branching, merging, and version tracking.
This guide will help you get started with Git by providing step-by-step instructions on how to download, install, and configure Git on your system, as well as basic usage examples.
To start using Git, follow these steps:
- Install Git: Download and install Git from the official website: https://git-scm.com/downloads
- Create a new repository: Open Git Bash (or your operating system's equivalent) and run the command
git init. This will create a new directory called.gitin your current working directory. - Make changes to your files: Create some sample files or modify existing ones to demonstrate how Git tracks changes.
git add <file_name>: Stage a file for the next commit. For example,git add README.mdgit add .: Stage all files in the current directory and its subdirectories.
git commit -m "Initial commit": Commit your staged changes with a meaningful commit message.
git log: View a list of all commits made to this repository, including dates and descriptions.git log --graph: Visualize the commit history as a graph.
git branch <branch_name>: Create a new branch based on the current branch. For example,git branch feature/new-featuregit checkout <branch_name>: Switch to the specified branch. For example,git checkout feature/new-feature
git merge <branch_name>: Merge changes from another branch into your current branch. For example,git merge feature/new-featuregit merge --no-commit: Merge changes without committing them.
- Remote repositories: Connect to a remote repository using
git remote add origin <repository_url> - Pushing and pulling: Push local changes to a remote repository with
git push -u origin master, or pull changes from the remote repository withgit pull origin master