git merge <branchname>
Merge the specified branch into the current branch, combining their histories.
git branch -m <old_branchname> <new_branchname>
Rename a branch
git fetch
Download new commits, branches, and tags from the remote without changing your current files.
git add -A
Add all new and changed files to the staging area
git restore --staged <path>
Unstages the specified file/s
git status
Show the status of the current repository
git branch
List all branches
git log
Show the commit history
git pull
Fetch and merge remote changes
git init
Initialize a Git repository in the current directory
git add <path>
Stages changes in the specified <path> so they are included in the next commit.
git commit -m "<message>"
Create a new commit with the staged changes and attach a message describing them.
git checkout <branchname>
Switch to a different branch
git commit -a
Commits any changes to tracked files in the current repository.
git checkout -b <branchname>
Create a new branch and switch to it
git push
Upload local commits from your current branch to its configured remote branch.
git rm -f <path>
Forcefully removes a file from the working directory and stages the deletion.
git tag -a <version_number>
Creates an annotated Git tag named `<version_number>` pointing at the current commit.
git diff HEAD
Show uncommitted changes
git cherry-pick <commitA>
Apply the changes introduced by <commitA> on top of the current branch.
git log --oneline --graph
Displays condensed repository history in a graphical format.
git checkout -
Switch back to the previously checked-out branch
git notes add -m <note-text>
Add a note to the current commit without altering its history
git stash save <message>
Stash changes with a custom message
git checkout HEAD <path>
Restore a file from the most recent commit
git diff HEAD --stat
View a summary of changes from the last commit
git branch -D <branchname>
Delete a branch forcefully
git stash
Temporarily saves changes that are not ready to be committed.
git diff --stat
View a summary of changes between your working directory and the staging area
git show <commit>
Displays content changes of a specific commit
git checkout -- <path>
Restore a file in the working directory to the version from the current branch or index.
git add -p
Interactively stage file changes
git clone <repo_url> <local_repo_name>
Creates a copy of a remote repository with a different name on your local machine
git push <remote> -d <branchname>
Delete a remote branch
git fetch <remote>
Download new commits, branches, and tags from a specific remote without changing your current work.
git rebase <branchname>
Replay your current branch’s commits on top of another branch to create a cleaner, linear history.
git commit --amend -m "<message>"
Replace the most recent commit with a new one using an updated message and staged changes.
git blame <path>
Show who last changed each line of a file and in which commit.
git cherry-pick --edit <commit>
Apply a specific commit on top of the current branch while opening the commit message for editing.
git show-ref --heads
Show commit hashes and reference names for all local branches.
git cherry-pick --continue
Resume an in-progress cherry-pick after resolving conflicts.
git grep -i "search pattern"
Search for patterns in the repository, ignoring the case of the search pattern
git reset <commit> --merge
Undo commits without touching the working tree.
git tag <version_number>
Create a new tag with the specified version number
git cherry-pick --no-commit <commit>
Apply the changes from a specific commit to the current branch without creating a new commit.
git diff @{push}
Compare your working directory to the commit recorded at your last push
git pull --rebase
Rebase the remote branch into the local one
git branch -a --contains <commit>
List all branches that contain commit <commit>, including remote branches.
git cherry-pick <commit-range>
Apply one or more existing commits from another part of the history onto the current branch.
git reset --soft HEAD~1
Undo last commit, keep changes staged.
git checkout --theirs <path>
Resolve a merge conflict by accepting the "incoming" branch changes
git config --global user.name <username>
Set your global Git username used to label your commits on this machine.
git cherry-pick --abort
Cancel an in-progress cherry-pick and restore the repo to its pre-cherry-pick state.
git reset --hard
Discard all changes and revert to the commit specified
git commit --no-verify
Commit changes without running pre-commit hooks
git add -i
Interactively add files to the git index
git stash apply
Apply the most recent stash to the working directory
git rebase --rebase-merges <branchname>
Rebase a branch incorporating merge commits.