preface

Git is a free open source distributed version control system that can quickly and efficiently process all content from small to large projects. This article will not talk about the principle of Git. Let’s take a look at its commands first

Control + F Quickly find keywords: Daily, clone, branch, History, Undo

Basic Settings (initialization)

  1. $git config –global user.name

  2. $git config –global user.name

  3. $git config –global user.email

  4. $git config –global user.email

  5. Ignore some files: $creates.gitignore files to which file names to ignore are written (example :node_modules /dist. Idea…) If the file to be ignored has been submitted to the repository, delete it and submit it again for the. Gitignore file to take effect

  6. Initialize the Git repository: $git init

Operation command

🏆 Routine Operations

  1. Add files to the repository: $git add.

  2. Add a single file to the repository: $git add test.text

  3. Add a file with a suffix: $git add *

  4. $git commit -m “Note”

  5. Push to the repository: $git push

💗 cloning

  1. The SSH or HTTP address of the $git clone project

  2. $git clone -b The SSH or HTTP address of the branch name project

🏡 branch

  1. Check all local branches: $git Branch

  2. To view all branches remotely: $git branch -r

  3. To view all local and remote branches: $git branch -a

  4. New branch: $git branch Name of the branch

  5. Create a new branch based on the remote branch and switch to the branch: $git checkout -b branch name Origin/remote branch

  6. Switch to the previous branch: $git checkout –

  7. $git branch -d branch name

  8. $git branch -d branch name

  9. $git remote prune Origin: $git remote prune Origin

  10. Merge branches: $git merge specifies the branch name (it will not commit automatically if there is a conflict)

  11. $git branch -m new branch name (not overwriting branches with the same name)

  12. $git branch -m

  13. Establish a trace relationship between an existing branch and a specified remote branch: $git branch –set-upstream Remote branch name

⌚️ Check the historical status

  1. Current status: $git status

  2. Check history: $git log

💊 Undo modification

  1. Undo all changes that have not yet been committed: $git checkout head.

  2. Undo a single suffix file that has not yet been committed: $git checkout head *. The suffix

The purpose of writing this article

At the end of 2020, the author successfully changed his job to a company. After entering the company, I found that there were a lot of front-end staff, and everyone relied on Git to manage the code, which made me very embarrassed. In my previous company, I was the only one at the front-end, and the code management was always add.commit -m push, which was definitely not enough. Therefore, I decided to compile a list of git commands commonly used in my work as a dictionary of operations at work, which I can refer to when I forget. Perfect! ✨

Back in 2020, although very sorry that I don’t have complete set the flag in 2019, but it’s been a very productive year, made a few good friends, and drink some wine over the weekend, blow brag, work and study the new knowledge at ordinary times, every day very substantial, in 2021, wish you in the New Year, new beginning, new job, new life continue to work hard, I also hope that you will not forget your original aspiration and forge ahead on the road of hard running. Come on, workers! ✊

There are many more Git commands, but I will improve this article later on