Software Development
Git
Frequent Used

Git

Create New Repository

Full Docs : Create a repo - GitHub Docs (opens in a new tab)

Frequently Used

Cancel Local Commits

git reset HEAD~1

Checkout and Create a new branch based on the previous branch

git checkout -b [branch-name]

Move Unstaged Changes to New Branch

git switch -c [new-branch]

Essentials

Branch

# move to a branch
git checkout <branch_name>
# create and move to a new branch
git checkout -b <branch_name>
# delete a branch
git branch -d <branch_name>
# rename a branch
git branch -m <renamed_branch>

Add

# add all changed files
git add .
# add a file
git add <file_relative_path>

Commit

git commit -m "your_commit_message"

Push

# push a branch which already connected and exist in remote
git push
# push a branch which doesn't exist on remote yet
git push -u <upstream> <branch_name>

Status

git status

Configurations

# read configured user in current repo
git config user.name
git config user.email
 
# read configured global user
git config --global user.name
git config --global user.email
 
# configure user in current repo
git config user.name "your_name"
git config user.email "your_email"
 
# configure global user
git config --global user.name "your_name"
git config --global user.email "your_email"

Initialization

git init