First, the concept of git
1, git: distributed management of distributed systems: client and server have version control capability
2, git role: managing source code
1, to facilitate collaborative development of more than
2, easy version control on the line of code ready to hang up. With the fastest speed back to the previous version
3, Warehouse: In our file if there is a code repository .git mark has been established
these files in the same directory .git managed together.
Two, git operation flow
1, git clone: local own warehouse, in general, only use it once
git the Add
git the commit
git the Push
git pull
Three, git composed of
local warehouse - remote repository
Workspace: Red
staging area: Green git add
warehouse district: clean clean git commit
Four, git operation command
1, the basic command
git init initialization warehouse
git add ./login.py added from the work area to the staging area
If you do not have a user name and mailbox specified submission, the system will default to the global
git config user.name ""
git config user.email ""
git commit -m "" committed to the warehouse district
git commit -am "" add and submit. Files are tracked, if a new file is created, it can not directly use
git status
git log to view information specific version
git reflog view brief information
2, version rollback
git reset --hard HEAD ^ / HEAD ~ 1 / version number
Modified version of git reflog every time, will produce record
3, undo changes in addition to the temporary storage area to work area
Workspace: git checkout xxx.py
Staging area: the HEAD xxx.py the RESET git
git Checkout xxx.py
4, compared to
Comparison between the different versions:
git diff version 1 version 2 xxx.py
The current version of the work area code comparison:
git diff the HEAD - xxx.py
linux for comparison: compare two files. vimdiff
5, delete
accidentally deleted: git checkout xxx.py
Really deleted: RM xxx.py
git RM xxx.py
git the commit -m ""
You can only delete the code, version of the record can not be deleted unless you really delete the entire code repository
Five people co-development
1, there is a git server information_zz12
2, git clone Https connection
. 3, Push git
. 4, git pull
When people develop collaborative case, the code will not avoid the conflict: Tips
reason: people simultaneously modify the same file
hazards: will affect the normal development progress
Note: Once the code conflict must be resolved to do follow-up development
Easy mode of operation conflict
more than one person operating the same file at the same time
a person has not written submission
does not modify the code before the latest update
does not update the latest code before submitting
allowed to modify the code colleagues
to reduce conflicts of operation
Develop good operating practices, to pull in changes immediately commit and push changes to your
must ensure that their files being modified is the latest version of
each developed their own modules
if you want to modify the public file, be sure to confirm that there is no one being modified
be sure to submit code before work, the first thing to go to work to pull the latest code
must not be allowed to modify the code of colleagues
Seven, playing Tag
1, Tag -a git "tag name" -m "comment"
2, git View Tag all Tag
3, the Push git Origin Tag v1.0
4, git Tag -d v1.0
5, the Push git Origin --delete tag v1.0
A version number of the provisions of unwritten
v1.1.0
A very large version
when we go to a project to add functionality when v1.22.22
when we went modify bug when v1.1.1
Eight branches of
action: you can do to further develop functionality and bug fixes on a branch
branch branch production environment and development environment
code is the difference between the production environment and the development environment
git branch branch name to create branches
git checkout to switch branches branch name
View branch git branch
git checkout -b branch name selection and create a branch name
git push origin branch name
It is first switched to the main branch
git merge develop development branch into the main branch
git workflow
Requirements: When you modify a lot of code, this time letting you do something else.
git stash code into memory
Wait until you're done with other matters to do their own thing in the back and
saved git stash pop out the code
https://gitee.com/loco_python/information_bj38.git