Commonly used Git commands

75 阅读1分钟

Connect to the remote repository

  1. initialize git: git init
  2. git add .
  3. git status
  4. git commit -m "Initial commit"
  5. git remote add origin https://github.com/your-username/your-repository.git
  6. git push -u origin master

Error: Please tell me who you are

Solution:

  • git config --global user.email "your email"
  • git config --global user.name "your name"

Branches

  • Create and delete a branch: docs.github.com/zh/pull-req…
  • Merge two branches:
    git branch -a: check all the branches
    git checkout main: change branch
    Say you want to merge based on main, then git merge master
    if there is no error, then: git push origin main
    if there are any conflict, you may need to handle it according to the situation and then commit.