Basics
working with local repositories
Getting and Creating Projects
git-init
Create an empty Git repository or reinitialize an existing one
git init [-q | --quiet] [--bare] [--template=<template-directory>]
[--separate-git-dir <git-dir>] [--object-format=<format>]
[--ref-format=<format>]
[-b <branch-name> | --initial-branch=<branch-name>]
[--shared[=<permissions>]] [<directory>]git-clone
Clone a repository into a new directory
git clone [--template=<template-directory>]
[-l] [-s] [--no-hardlinks] [-q] [-n] [--bare] [--mirror]
[-o <name>] [-b <name>] [-u <upload-pack>] [--reference <repository>]
[--dissociate] [--separate-git-dir <git-dir>]
[--depth <depth>] [--[no-]single-branch] [--no-tags]
[--recurse-submodules[=<pathspec>]] [--[no-]shallow-submodules]
[--[no-]remote-submodules] [--jobs <n>] [--sparse] [--[no-]reject-shallow]
[--filter=<filter> [--also-filter-submodules]] [--] <repository>
[<directory>]Snapshotting
git-add
Add file contents to the index
git-status
Show the working tree status
git-diff
Show changes between commits, commit and working tree, etc
git-commit
Record changes to the repository
To trigger a commit and kickoff workflow without having to make any change.
git-notes
Add or inspect object notes
git-restore
Restore working tree files
git-reset
Reset current HEAD to the specified state
--soft- move changes back to staging(index) area.This is helpful if you want to take a group of commits and squash them into a single larger commit.
--mixed(default) - move changes back to local working directory.this is helpful if you want to take a group of small commits and combine some of the changes to make larger commits, and you can also use it to make additional changes to the files and then re-create the commit history.
--hard- moves changes to the trash.
git-rm
Remove files from the working tree and from the index
git-mv
Move or rename a file, a directory, or a symlink
Branching and Merging
branch- List, create, or delete branchescheckout- Switch branches or restore working tree filesswitch- Switch branchesmerge- Join two or more development histories togethermergetool- Run merge conflict resolution tools to resolve merge conflictslog-stash- Stash the changes in a dirty working directory awaytag- Create, list, delete or verify a tag object signed with GPGworktree- Manage multiple working trees
git-branch
git-log
Show commit logs
=========================================================================
Recursive Merge A recursive merge occurs when your feature branch doesn’t have the latest version of code in the branch you’re trying to merge into.

Fast-Forward Merge A fast-forward merge occurs when there have been no new commits, other than the ones you’re trying to merge, on the original branch since you created your feature branch from it.

Branches
Rename Branch
If you want to rename your current HEAD branch,
If you want to rename a different local branch that is not currently checked out,
Switch Branch
Track Branch
when we want to track a remote branch,
when we want the same name for the local branch as the remote branch then,
Rebase Branch
first switch to the branch that should receive changes
then execute the "rebase" command with the name of the branch that contains the desired changes
Compare Branch
to compare two branches,
to compare local and remote branch,
to see the actual changes that make up those differences between branches,
Last updated
Was this helpful?