DEV Community

Cover image for GIT Commands Summary
Thalhatou Yahya
Thalhatou Yahya

Posted on

1

GIT Commands Summary

Introduction :
Git is a version control system that allows developers to track changes to files and collaborate with others on software projects. It allows users to create different versions or "branches" of a project, and merge those branches together when they are ready to be released. Git also allows users to revert to previous versions of a project if necessary. It is widely used in the software development industry and is a crucial tool for collaborative projects.
Here are commonly used git commands summarized.

git init - Initialize a new Git repository in the current directory
Example: git init

git clone - Clone an existing repository from a remote location
Example: git clone https://github.com/user/repo.git

git add *- Add files to the staging area for commit
Example: git add . (to add all modified and untracked files)
*

git commit
- Commit the changes in the staging area to the repository
Example: git commit -m "added new feature"

git push - Push the committed changes to a remote repository
Example: git push origin master

git pull - Pull changes from a remote repository to the local repository
Example: git pull origin master

git branch - Create, list, or delete branches in the repository
Example: git branch new-branch (to create a new branch)

git checkout - Switch to a different branch in the repository
Example: git checkout new-branch

git merge- Merge two branches together
Example: git merge new-branch

git diff- Compare differences between two commits or files
Example: git diff HEAD~1 HEAD (to compare the previous commit with the current commit)

git log- View the commit history of the repository
Example: git log --oneline (to view a concise summary of the commit history)

git stash - Save changes temporarily without committing them
Example: git stash save "work in progress"

git tag - Tag specific commits with a label
Example: git tag v1.0

git reset - Undo commits and move the HEAD pointer to a previous commit
Example: git reset HEAD~1 (to undo the previous commit)

git fetch- Download objects and refs from a remote repository
Example: git fetch origin

git config- Set configuration options for the repository
Example: git config --global user.name "Yong Addy"

git remote - Manage remote repository connections
Example: git remote add origin https://github.com/user/repo.git

git show **- Show details of a specific commit or object
Example: git show HEAD (to view the details of the current commit)

**git blame
- Show the commit and author information for each line of a file
Example: git blame file.txt

git ls-files- List all the files in the repository
Example: git ls-files

git ls-remote- List references in a remote repository
Example: git ls-remote origin

git gc- Perform garbage collection on the repository
Example: git gc

git archive- Create a tar or zip archive of the repository
Example: git archive --format=zip --output=archive.zip HEAD

git rev-parse - Parse revision information and display it in a useful format
Example: git rev-parse HEAD

git grep - Search for a pattern in the repository
Example: git grep "pattern"

git cherry-pick- Apply the changes from a specific commit to the current branch
Example: git cherry-pick abc123

git bisect - Perform a binary search through the commit history to find a bug
Example: git bisect start HEAD HEAD~100

git am- Apply a patch to the repository

Thanks for checking it out hope the list was helpful.

Image of Datadog

Create and maintain end-to-end frontend tests

Learn best practices on creating frontend tests, testing on-premise apps, integrating tests into your CI/CD pipeline, and using Datadog’s testing tunnel.

Download The Guide

Top comments (0)

nextjs tutorial video

Youtube Tutorial Series 📺

So you built a Next.js app, but you need a clear view of the entire operation flow to be able to identify performance bottlenecks before you launch. But how do you get started? Get the essentials on tracing for Next.js from @nikolovlazar in this video series 👀

Watch the Youtube series

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay