10 most usable git command

Umar Farooque Khan
2 min readOct 27, 2023

--

1. git init

Initializes a new Git repository, creating a hidden folder where Git tracks version history and manages changes.

git init

2. git clone [repository URL]

Copies a remote repository onto your local machine, allowing you to work on the code base.

git clone https://github.com/example/repo.git

3. git add [file]

Stages specific changes for commit, preparing them to be included in the next commit snapshot.

git add myfile.txt

4. git commit -m “[commit message]”

Records changes made to the repository, creating a commit with a descriptive message for future reference.

git commit -m "Added new feature"

5. git push

Uploads committed changes from your local repository to the remote repository, ensuring version synchronization.

git push origin master

6. git pull

Fetches changes from the remote repository and merges them into your current working branch.

git pull origin master

7. git branch

Displays a list of existing branches in your repository, highlighting your current branch.

git branch

8. git checkout [branch name]

Switches your working environment to the specified branch, enabling you to work on it.

git checkout feature-branch

9. git merge [branch name]

Combines changes from a different branch into your current branch, integrating new features or bug fixes.

git merge feature-branch

10 git status

Provides an overview of the current repository status, indicating modified, staged, and committed files.

git status

--

--

Umar Farooque Khan
Umar Farooque Khan

Written by Umar Farooque Khan

Experienced software developer with a passion for clean code and problem-solving. Full-stack expertise in web development. Lifelong learner and team player.

Responses (1)