# clone target repo first and move to the directory
git clone <target_repo>
cd <target_repo_dir>
# create a branch
git checkout -b <branch_name>
# do something
# COMMIT step
git add .
git commit -m "<commit_details>"
# PUSH step
git push origin <branch_name>
git branch -d <specific_branch>
git push origin :<specific_branch>
git branch
# switch to master
git checkout master
# switch to specific branch
git checkout <specific_branch>
# before add command
git checkout -- <file>
# before commit, after add command
git reset
git checkout -- <file>
# check every commit
git log --oneline
# revert back to the specific commit
git checkout <specific_commit_hash>
# remove the latest commit
git revert <latest_commit_hash>
# do something for new commit
# COMMIT step
# if change something ......
git add .
git commit -m "<commit_details>"
# else ......
git commit -a
# PUSH step
git push origin HEAD:<branch_name> -f
# --------------------------------------------------
# however, HEAD detached at <detached_commit_hash>
# --------------------------------------------------
# check branch
git branch # || git branch -v
# create a temp branch for the detached HEAD
git branch <tmp_branch_name> <detached_commit_hash>
# checkout and merge temp branch to original branch
git checkout <branch_name>
git merge <tmp_branch_name>
# if conflict then after resolving
git add .
git commit -m "<commit_details>"
git push origin <branch_name> # if on master: git push