Moment For Technology

Git Learning Notes

Posted on Aug. 8, 2022, 7:18 p.m. by 鄧美琪
Category: The development tools Tag: git

This article only personal notes, move brick part more

Code cloud git complete

Code cloud git command learning

Learn the command part to understand how it works, and it's better to use a tool

The following part has a personal understanding, if there is a mistake, hope to correct

The main command

The local part

  • Git add // Add to staging
  • Git commit //
  • Git checkout branch1; Create and switch Git checkout -b branch1
  • Git branch branch1;
  • Git merge git merge branch1
  • Git rebase // git rebase; Git rebase master branch1: create branch on master branch
  • Git branch -f a b // Force change a branch location to b commit
  • Git reset HEAD^ git reset HEAD^
  • Git Revert // Unshare This post with git Revert HEAD
  • Git cherry-pick git cherry-pick hash1 hash2 hash3...
  • Git rebase -i git rebase -i HEAD~4
  • Git commit --amend // Modify the commit record of the latest node type I after modification esc :wq
  • Git stash // Stash save "description" apply stash@{1} drop stash@{1} clear clear list
  • Git tag // Create a tag git tag describes the node

The remote part

  • Git remote show
  • Git clone // Clone the remote git clone URL
  • Git fetch // fetch the remote code, but the development zone is unchanged, only the remote branch image update (parameter is the same as git pull), no parameter will update all the remote branch, it is recommended to use git fetch -p, you can delete the remote deleted branch
  • Git pull // Fetch remote code locally, similar to git fetch; Git pull remote host name : local branch name
  • Git push remote host name local branch name
  • Git push origin :branch1
  • Git fetch origin :bar
  • Git checkout -b branch1 origin/master git checkout -b branch1 origin/master
  • Git branch -u origin/master branch1

Auxiliary commands (better to help us use action commands)

  • Git help git help
  • Git log + --oneline + --graph to display tree output
  • Git status // displays the changed files with -s output
  • Git diff // displays differences between staging and workspace
  • Git branch // View local branches -a View remote and all local branches -r View remote branches

Methods using

  • Git checkout -- [filename...]
  • Reset HEAD~ // HEAD~ can also be the hash code to commit
  • Git reset HEAD or file name
  • Git reset -- git reset HEAD~ git checkout -- ...

To be continued...

Search
About
mo4tech.com (Moment For Technology) is a global community with thousands techies from across the global hang out!Passionate technologists, be it gadget freaks, tech enthusiasts, coders, technopreneurs, or CIOs, you would find them all here.