top of page
Search

Git Commands Cheat Sheet

  • Writer: Emilia
    Emilia
  • 7 days ago
  • 1 min read

Git is an essential tool for developers, helping you track changes, collaborate, and manage project versions efficiently. Here’s a compact cheat sheet of must-have Git commands that every developer should know.


# Initialize a new repository
git init

# Clone an existing repository
git clone [url]

# Add a connection to a remote repository
git remote add origin <address>

# Stage changes for commit
git add .

# Commit changes with a message
git commit -m "Your message here"

# Edit the most recent commit
git commit --amend

# Check the status of your files
git status

# Push changes to the remote repository
git push origin main

# Fetch updates and merge from remote
git pull origin main

# List, create, or delete branches
git branch

# Switch branches or restore files
git checkout -b new-branch

# Combine changes from one branch into another
git merge feature-branch

# Squash commits into one based
git rebase -i HEAD~n

# Pick a specific commit from another branch
git cherry-pick [commit-hash]

# Stash your changes temporarily
git stash

# Apply your stashed changes to a new branch
git stash apply

# Retrieve stashed work to the working directory
git stash pop

# View the commit history
git log

Conclusion

These commands cover essential Git tasks and are perfect for saving as a quick reference. Keep this cheat sheet handy to streamline your version control processes. Happy coding!

 
 
 

Comments


bottom of page