Git basic use

Work with local repo

create repo

  • create repo on github directly
  • git bash
    • create a folder and go to that folder
# make directory a git repository git init

主要步骤

git fetch --0 #版本更新
git pull origin master #下载
git push origin master #推上

git add

git add . # add all files git add <file_or_directory_name>

git commit

git commit -m "commit_message"

git status

git status # returns the current state of the repository

git branch

git branch <branch_name> # create a new branch git branch -a # list all branches git branch -d <branch_name> # delete a branch

git merge

git merge <branch_name>

Work with remote repo

git remote

git remote <cmd> <remote_name> <remote_url> git remote -v

git pull

git pull <branch_name> <remote_URL/remote_name> git pull origin https://github.com/....git

git push

git push <remote_URL/remote_name> <branch> git push origin main

git rm

git rm <file_name> # delete a file
tags: git