git checkout -b branch |
Create a new branch with the name branch |
git add filename(s) |
Stage files in preparation for committing them to the repository |
git commit |
Save the staged changes to the repository |
git checkout branch |
Switch to the specified branch |
git merge branch |
Incorporate the commits from the branch branch into the current branch |
git branch --delete |
Remove a local branch |
git branch -D |
Remove al local branch whose commits are not incorporated elsewhere |
git clone URL |
Create a local copy of a remote repository |
git log |
Read the commit history for this branch |
git reflog |
Read the extended history for this branch |
git checkout commit |
Check out a specific commit; puts you into a detached HEAD state |
git cherry-pick commit |
Copy a commit from one branch to another |
git reset --merge ORIG_HEAD |
Remove from the current branch all commits applied during a recent merge |
git checkout --filename |
Restore a file that was changed, but has no yet been committed |
git reset HEAD filename |
Unstage a file that is currently staged so that its changes are not saved during the next commit |
git reset --hard HEAD |
Restore all changed files to the previously stored state |
git reset commit |
Unstage all of the changes that were previously committed up to the commit right before this point |
git rebase --interactive commit |
Edit, or squash commits since commit |
git rebase --continue |
After resolving a merge conflict, continue with the rebasing process |
git revert commit |
Unapply changes stored in the identified commit; this creates a sharing friendly reversal of history |
git log --oneline --graph |
Display the graphed history for this branch |
git revert --mainline 1 commit |
Reverse a merge commit |
git branch --contains commit |
List all branches that contain a specific commit object |
git revert --no-commit last_commit_to_keep..newest_com |
Reverse a group of commits in a single commit, instead of creating an object for every commit that is being undone |
git filter-branch |
Remove files from your repository permanently |
git reflog expire |
Forget about extended history, and use only the stored commit messages |
git gc --prune=now |
Run the garbage collector and ensure all noncommitted changes are removed from local memory |