git command line operation instructions

  1. git config --global user.name "username"
  2. git config --global user.email "mailbox"
  3. pwd shows the current directory
  4. get init turns the current directory into a repository that git can manage
  5. git add "filename" adds files/folders to the repository, you can add multiple files separated by spaces
  6. git commit -m "commit information" tells git to submit the file to the repository, but first execute the git add command on the file
  7. git status Get the current status of the repository
  8. git diff "filename" to view the modified content of the specified file
  9. git log View the log, you can add the suffix --pretty=online
  10. git reset --hard HEAD^ Go back to the previous version, the current version of HEAD, the previous version of HEAD^, the previous version of HEAD^^, and the commit id can also be used.
  11. cat "filename" opens the current document
  12. get reflog View operation records
  13. git diff HEAD -- "filename" to see the difference between the workspace's document and the latest document in the repository
  14. git checkout -- "filename" Undo changes to the workspace and replace the workspace files with the latest files from the repository
  15. git reset HEAD "filename" to undo the changes in the staging area
  16. rm "filename" deletes the file in the file manager
  17. git rm "filename" removes this file from the repository, then commits using the command git commit
  18. ssh-keygen -t rsa -C "mailbox" requires the email address verified in GitHub
  19. git remote add origin [email protected]:yourGitHubUsername/yourProfile will associate the remote repository locally
  20. git push -u origin master pushes the current master branch to the remote repository, -u associates the local branch with the remote branch
  21. git clone [email protected]:yourGitHubUsername/yourProfile clone from remote repository to local
  22. git checkout -b dev creates a dev branch, -b means create and switch to dev
  23. git branch View current branch
  24. git checkout master switches to the master branch
  25. git merge dev merges the dev branch into the current branch
  26. git branch -b dev delete the dev branch
  27. git merge --no-ff -m "commit information" dev --no-ff forcibly prohibits Fast forward, merge branches and delete branches without losing branch information
The above content is excerpted from Liao Xuefeng's git tutorial from     Liao Xuefeng's git tutorial

Guess you like

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