Understand github common commands one (merge branches, reference moves, undo commits)

An interesting little game for learning github commands

All the screenshots in this article are from this mini game and are only for personal study records. If there is any infringement, please contact me to delete

github common commands

  • git commit: The commit command will create a new commit record;
  • git checkout branchName: switch the branch to the branch named branchName;
  • git branch branchName: create a new branch named branchName;
  • cat .git/HEAD: Check HEAD points to
  • git symbolic-ref HEAD: If HEAD points to a reference, you can use this command to check HEAD points to

Merge branch command (* sign indicates the reference pointed to by HEAD, that is, the reference currently pointed to)

  • git merge branchName: merge the branchName branch into the branch pointed to by the current reference
    write picture description here
    write picture description here

  • git rebase branchName: merge the current branch into the branchName branch (the opposite of the git merge command)
    write picture description here
    write picture description here
    write picture description here
    write picture description here

move up the commit tree

  • The concept of HEAD
    write picture description here
  • git checkout commit record name: detach HEAD, let HEAD point to the commit record, not the reference
    write picture description here
    write picture description here
  • git checkout branchName^: Find the parent commit of the specified commit record
    write picture description here
    write picture description here
    write picture description here

  • git checkout branchName~2: Find the parent and parent commit of the specified commit record, equivalent to git checkout branchName^^
    write picture description here
    write picture description here
    write picture description here

  • git branch -f master HEAD~3: Point the master reference to the parent parent commit record of HEAD, as shown below
    write picture description here

revoke order

  • git reset Relative positioning: roll back to the positioned position ( only valid for local branches, invalid for remote branches ). Relative positioning, such as master~2, represents the first two commit records of the commit record pointed to by the master reference.
    write picture description here
    write picture description here

    • git revert relative positioning: roll back to the positioned position ( valid for remote branches ).

    write picture description here
    write picture description here

Guess you like

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