git
Master Git with our comprehensive cheatsheet. Quickly find essential Git commands for adding, committing, branching, merging, and more. Boost your version control efficiency.
Git Cheatsheet
This Git cheatsheet provides essential commands for efficient version control. Whether you're a beginner or an experienced developer, this guide will help you quickly access common Git operations.
Version Control Fundamentals
Git is a distributed version control system that helps developers track changes in their codebase, collaborate with others, and manage project history effectively. Understanding core Git commands is crucial for any software development workflow.
Common Git Operations
Here are some of the most frequently used Git commands:
[main]
name=git
desc=My awesome git cheatsheet
[cheats]
Add file to staging area = git add <FILENAME>
Change remote URL = git remote set-url origin <URL>
Create remote branch = git push -u origin <BRANCHNAME>
Clone a remote git repository = git clone <URL>
Delete a merged branch = git branch -d <BRANCHNAME>
Differences in two branches = git diff <BRANCH_A> <BRANCH_B>
Fetch and Rebase = git pull --rebase
List changes since two weeks = git whatchanged --since=<TIME>
List of all files changed in a commit = git diff-tree --no-commit-id --name-only -r 'commit'
List of all files till a commit = git ls-tree --name-only -r 'commit'
Lists all stashed changesets = git stash list
Merge branch with master = git merge <BRANCHNAME>
Push to diffent branch = git push origin <BRANCHNAME>
Quickly switch to the previous branch = git checkout -
Rebase current HEAD = git rebase <BRANCHNAME>
Remove remote branch = git push origin --delete <BRANCHNAME>
Rename a branch = git branch -m <NEW_NAME>
Restore a stash = git stash apply 'stash'
Revert a commit with new commit = git revert 'commit'
Revert local changes in file = git checkout HEAD <FILENAME>
See all merged branches = git branch --merged master
See all unmerged branches = git branch --unmerged
See everyday git examples = git help everyday
See who changed what in a file = git blame <FILENAME>
Set editor for commits = git config --global core.editor <EDITORNAME>
Set git alias = git config --global alias.co commit
Set user name = git config --global user.name <USER_NAME>
Set user email = git config --global user.email <USER_EMAIL>
Show Remote Url = git config --get remote.origin.url
Temporarily stores all modified tracked files = git stash
Undo all commits after = git reset 'commit'
Add a remote upstream repo = git remote add upstream <URL>
Sync with remote upstream repo = git pull upstream master
Append new commit to keep single commits = git commit -a --amend
List branches of remote repo = git branch -r
Advanced Git Techniques
Explore more advanced Git commands for complex scenarios, such as rebasing, reverting commits, and managing remotes effectively. These commands are vital for maintaining a clean and organized project history.
Further Resources
For more in-depth information on Git, refer to the official documentation and community resources: