DEV Community

Cover image for Mastering Advanced Git Commands
Kaviyarasu S
Kaviyarasu S

Posted on

Mastering Advanced Git Commands

Git is a powerful tool, and knowing some advanced commands can really level up your version control game. In this post, we'll go through some commonly used Git commands along with their purpose, how to use them.

1. git diff

Purpose: Show differences between two commits or working directory and index.

Command: git diff

Image description

2. git log

Purpose: Show commit history.

Command: git log

Image description

3. git clone

Purpose: Clone a remote repository to your system.

Command: git clone https://github.com/Kavi-26/24MCR054

Image description

4. git pull

Purpose: Pull changes from remote to local repo.

Command: git pull origin main

Image description

5. git push

Purpose: Push local commits to remote.

Command: git push origin main

Image description

6. git blame

Purpose: Show who last modified each line of a file.

Command: git blame ML.txt

Image description

7. git merge conflict (not a command)

Note: Conflict occurs during a git merge.

Here’s how to simulate:

git checkout -b new-branch

git checkout main

git merge new-branch

8. git branch

Purpose: List, create, or delete branches.

Command: git branch

Image description

9. git checkout -b

Purpose: Create and switch to a new branch.

Command: git checkout –b advanced-git-commands

Image description

Image description

Image description

Image description

10 .gitignore

Purpose: File to specify untracked files to ignore.

Steps:

Create .gitignore file in root directory.
Add file patterns to ignore.

e.g.:

*.log
node_modules/

No command needed, Git automatically ignores the specified files.

Github Repository:

Github link: https://github.com/Kavi-26/24MCR054

Image description

Image description

Image of Stellar post

🚀 Stellar Dev Diaries Series: Episode 1 is LIVE!

Ever wondered what it takes to build a web3 startup from scratch? In the Stellar Dev Diaries series, we follow the journey of a team of developers building on the Stellar Network as they go from hackathon win to getting funded and launching on mainnet.

Read more

Top comments (0)

👋 Kindness is contagious

Explore a trove of insights in this engaging article, celebrated within our welcoming DEV Community. Developers from every background are invited to join and enhance our shared wisdom.

A genuine "thank you" can truly uplift someone’s day. Feel free to express your gratitude in the comments below!

On DEV, our collective exchange of knowledge lightens the road ahead and strengthens our community bonds. Found something valuable here? A small thank you to the author can make a big difference.

Okay