1.1 git Usage Summary
1.2 git introduction
Powerful and free distributed version control system.
Originated from the Linux community, in order to meet the needs of Linux developers around the world for code version management
GitHub / gitlab is essentially an online code hosting website based on Git
1.3 general operation of GIT
Start work every day, you must pull the code first
Pull the code before each submission
Git add and. Gitignore
The GIT add command is used to add the specified file / folder to the staging area. Generally, you can use git add. To add the current directory to the staging area. During the addition process, GIT ignores the exception files / folders specified in. Gitignore by default. . gitignore configuration syntax is as follows:
The beginning indicates a comment. The path relationship needs to compare the location of the target and the. Gitignore file
Git reset head and git RM
It is easy to understand that git reset head can be used to clear the temporary storage area, which is the reverse operation of GIT add.
The GIT RM command is used to delete files from the cache or working directory. –The cached parameter can be used to specify the branch name / specific file name, which means that only files are removed from the cache and local source files are reserved.
Git pull and git push
Git pull can be regarded as the merge command of GIT fetch and git merge. It is equivalent to executing git fetch origin and git merge fetch head to get the code of the specified branch on the server and merge with the local code. It is recommended to write full commands such as: git pull origin dev: dev
Git push, full write: git push origin dev: dev, command format is git push origin < local branch >: < remote branch > version rollback (risky!)
Git log – 5 or git reflog view the latest 5 commits / all commits, select the version to roll back, and copy the version number
Run git reset — hard ee6332c4cf3a05c600f5ab02077104b9d496cca1 to roll back to the specified version (local warehouse). Run git push – f origin master: master to force submission to the remote warehouse. ! > the GIT reset command with the — hard parameter is dangerous. It can overwrite the local code and cause work loss, so it should be used with caution.
! [rejected]… (non fast forward) method 1: git pull origin master — allow unrelated histories method 2: git fetch origin master, GIT merge fetch － head
cd existing_folder git init git remote add origin
git add . git commit -m “Initial commit” git push -u origin master
Add new branch git fetch origin SaaS git checkout – B SaaS origin / SaaS
My entrepreneurial team product, madpecker, is mainly engaged in bug management, test management and application distribution
Website: www.maddecker.com, welcome to try and experience if you need!
This article is written for technicians of madpecker team. Please indicate the source for reprint