Skip to content

Git Commands

atakemin edited this page Feb 20, 2025 · 1 revision

Git Commands Cheat Sheet

Git is a powerful version control system that helps developers track changes in their projects. Below is a summary of essential Git commands categorized by their purpose.

1. Configuration

Command Description
git config --global user.name "Your Name" Sets the global username for Git commits
git config --global user.email "[email protected]" Sets the global email for Git commits
git config --list Displays the current Git configuration

2. Repository Management

Command Description
git init Initializes a new Git repository
git clone <repo-url> Clones an existing repository

3. Working with Changes

Command Description
git status Shows the status of changes in the working directory
git add <file> Stages a file for commit
git add . Stages all changes
git commit -m "Your message" Commits staged changes with a message
git commit --amend -m "New message" Amends the last commit message

4. Branching & Merging

Command Description
git branch Lists all branches
git branch <branch-name> Creates a new branch
git checkout <branch-name> Switches to a different branch
git checkout -b <branch-name> Creates and switches to a new branch
git merge <branch-name> Merges a branch into the current branch
git rebase <branch-name> Reapplies commits on top of another base branch

5. Remote Repositories

Command Description
git remote -v Lists remote repositories
git remote add <name> <url> Adds a remote repository
git push <remote> <branch> Pushes local changes to a remote repository
git pull <remote> <branch> Fetches and merges changes from a remote repository
git fetch <remote> Fetches changes from a remote repository without merging

6. Undoing Changes

Command Description
git reset <file> Unstages a file
git reset --hard <commit> Resets to a previous commit and discards all changes
git revert <commit> Creates a new commit that undoes a previous commit
git checkout -- <file> Discards changes in a working directory file

7. Logs & History

Command Description
git log Shows commit history
git log --oneline Shows a concise commit history
git diff Shows changes between commits, branches, or working states

8. Stashing Changes

Command Description
git stash Saves uncommitted changes for later
git stash pop Applies the last stashed changes and removes them from stash
git stash list Lists all stashed changes

9. Tags

Command Description
git tag Lists all tags
git tag -a v1.0 -m "Version 1.0" Creates an annotated tag
git push origin --tags Pushes tags to a remote repository

10. Additional Tips

  • Use git help <command> to get detailed documentation on a specific command.
  • Use git alias to create shortcuts for frequently used commands.

This cheat sheet provides an overview of fundamental Git commands. For more details, refer to the official Git documentation.

Team Members

Meeting Notes

Project Resources

Software Design Diagrams

Templates

Research on Git

Documentation(Manuals & Research Doc)



Documentation(Individual Contributions and/or Milestone Report)

Individual Contributions

Projects

Clone this wiki locally