git common commands

git common commands

View content

branch

  • View which branch you are currently in | View all local branches
    git branch -v
  • View all branches, including remote
    git branch -a
  • View the remote branch tracked by the current branch
    git remote -v

get content


configure

  • View when the content of the global configuration or the current value
    git config -list

branch

  • View remote branches to which all branches belong
    git branch -vv
  • checkout the current branch from the remote branch
    • First delete the current branch name, such as dev
      git branch --delete dev
    • Check out to the specified branch
      git checkout 远程分支名 -b 本地分支名
  • switch branch
    git checkout 分支名

    • code
      $ git checkout 分支名  
      M       jingwei-server/src/main/java/com/taobao/jingwei/server/service/cmd/GetCustomerTarCmd.java  
      M       jingwei-server/src/main/java/com/taobao/jingwei/server/util/ServerUtil.java  
      Switched to branch 分支名  
      // M 代表修改的内容
  • View branch commit records
    git log
    git log -p -2


    • Add nothing, all updates will be listed
      -p expand each commit difference
      -2 view the last 2 commits

Modify the content

branch

  • Add branch
    git branch branch name
  • Modify the local branch name
    git branch -m master masterName
  • delete branch
    git branch -d branch name
  • delete remote branch
    linux
    git branch -r -d 分支名(记得加origin)
    git push origin 分支名
  • initialize git
    git init
  • add git address
    git remote add origin url
  • Pull first, then push
    git pull origin master
    git push -u origin master

    -u means to specify a default host, no need to add parameters for future push, use it directlygit push

  • Set the url pointed to by the local branch (you can push in two batches when pushing)
    • git remote set-url --add origin url
    • --deleteyes delete
  • Set the local branch to point to the remote branch.
    git branch --set-upstream master origin/分支名称
    If not set, you need to manually enter the remote branch name each time
    git pull origin master

document

  • Discard the modified
    git checkout filename of the current file

push content

branch

  • Push the current branch to the remote branch
    git push orign branch name

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324658433&siteId=291194637