git clone https://github.com/zhenluo666/GitTutorial
--- Instead of cloning, you can also creat a new repository at local machine (go to the directory at your local machine)
git init
git remote add origin https://github.com/zhenluo666/GitTutorial
git status
3. Include untracked files or update unstaged files at git status check (after you make changes to files in local repository)
git add {filename}
git add .
git add *
git add -A
git restore {filename}
git commit -m "updated the README with more commands"
git add . && git commit -m "add more lines"
git log
git push
git push -u origin main
git push origin {new_remote_branch}
--- Retrieve/Fetch remote-tracking branches (After fetch, you can merge the received commits into local branch using git merge)
git fetch
git fetch {remote_repository} {remote_branch}
git pull
git pull origin {remote_branch}:{local_branch}
git pull {remote_repository} {remote_branch}:{local_branch}
git checkout -b {new_local_branch} origin/{remote_branch}
% Note pull may create merge conflict between remote and local that you need to be fix and commit the change
:q
:q!
:wq
git config --global --edit
git --help
git reset {filename}
git reset --hard origin/{branch_name}
git remote -v
git branch -a
git diff {main_branch} {new_branch}
git branch {new_branch}
git branch {new_branch} {base_branch}
git branch {new_local_branch} {remote_repository}/{remote_branch}
git checkout -b {new_branch}
git checkout -b {new_local_branch} origin/{remote_branch}
git checkout {branch_name}
git branch --list
git branch -D {branch_to_be_deleted}
git branch -M {branch_to_be renamed}
git branch -C {branch_to_be_copied}
git push origin --delete {remote_branch_to_be_deleted}
git merge {branch_name}
git fetch origin {remote_branch} && git merge origin/{remote_branch}
git fetch {remote_repository} {remote_branch} && git merge {remote_repository}/{remote_branch}
% There may be merge conflict which needs your check into files and make modifications
% Merge conflict has to be resolved before switch branch