Git Installation Commands
Step 1: Update the System
- Run these commands to update your system’s package list and install the latest versions of packages.
sudo apt update
sudo apt upgrade
Step 2: Finish the Git Installation
- Use this command to install Git along with additional packages.
sudo apt install git-all
Step 3: Verify Installation
- Use the below command to varify the installation of Git version
git --version
Basic Git Commands with Examples
1. Checking Git Version
- Before starting with any Git operations, it’s essential to check if Git is installed correctly on your system. The following command will show you the version of Git installed:
git --version
*2. Initializing a Git Repository (git init)
*
- To start tracking a project using Git, you need to initialize a new Git repository in your project directory.
- Initialize Git Repository: Once you're in the project directory, run the following command to initialize a Git repository:
git init
3. Git Configuration
- After that, configure your username and email:
git config --global user.name "your Name"
git config --global user.email "your.email@example.com"
- Adding Files to Staging Area
- When we get to know which files are not added by typing git status(red-colored files are not added).
- To track a file or prepare changes for commit:
git add <file_name>
- To add all Files:
git add .
- Committing Changes
- Files displayed in green are staged but not yet committed. To commit these changes, use:
git commit -m "Your commit message"
6.Pushing Changes to GitHub
- To upload commits to your forked repository
git push origin <branch_name>
REFERED LINKS
Top comments (0)