All Git command

Posted by

# Configure Git with user details
git config --global user.name "Your Name"
git config --global user.email "you@example.com"

# Initialize a new Git repository
git init

# Clone an existing repository
git clone https://github.com/username/repository.git

# Check the status of your repository
git status

# Add files to the staging area
git add <file>
git add .  # Add all files

# Commit changes
git commit -m "Commit message"

# Add a remote repository
git remote add origin https://github.com/username/repository.git

# Push changes to the remote repository
git push origin master

# Pull changes from the remote repository
git pull origin master

# Check the commit history
git log

# Create a new branch
git branch <branch_name>

# Switch to a branch
git checkout <branch_name>

# Create and switch to a new branch
git checkout -b <branch_name>

# Merge a branch into the current branch
git merge <branch_name>

# Delete a branch
git branch -d <branch_name>

# Stash changes (temporarily save changes)
git stash
# Apply stashed changes
git stash apply

# Show changes between commits or the working directory and index
git diff

# Show detailed information about a commit
git show <commit>

# Add a tag to a commit
git tag -a v1.0 -m "Version 1.0"

# Push tags to the remote repository
git push origin --tags

# Revert changes
git revert <commit>

# Reset the current HEAD to a specific state
git reset --hard <commit>
Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x