Logo

Basic Git Commands Guide

This guide provides a quick reference for basic Git commands on Ubuntu. Git is a powerful version control system widely used for collaborative development.

Table of Contents

  1. Setting Up Git
  2. Cloning a Repository
  3. Checking Repository Status
  4. Making Changes
  5. Committing Changes
  6. Branching
  7. Merging
  8. Pushing Changes
  9. Pulling Changes
  10. Viewing Commit History

1. Setting Up Git

Install Git on Ubuntu:


sudo apt update
sudo apt install git

Configure your name and email:


git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"

2. Cloning a Repository

Clone a remote repository to your local machine:


git clone https://github.com/username/repository.git

3. Checking Repository Status

Check the status of your local repository:


git status

4. Making Changes

Create or modify files in your working directory.

5. Committing Changes

Stage changes for commit:


git add filename

Commit changes with a descriptive message:


git commit -m "Your commit message"

6. Branching

Create a new branch:


git branch new-branch

Switch to the new branch:


git checkout new-branch

7. Merging

Merge changes from one branch into another:


git checkout target-branch
git merge source-branch

8. Pushing Changes

Push changes to a remote repository:


git push origin branch-name

9. Pulling Changes

Pull changes from a remote repository:


git pull origin branch-name

10. Viewing Commit History

View commit history:


git log

These are some basic Git commands to get you started. Explore more Git functionalities as you continue with your development projects.


Go back to GitHub Guide.

Visit other Developer Guides.