Workspace workspase Staging Area stage version Library Master difference
The workspace is the file under the current file system, so open the folder directly to see
Staging area is the place where the repository is temporarily saved through Git add, followed by a commit to a branch on the repository using git commit
The equivalent of a backup after submission to the repository, which can be restored to the workspace later
User 2 Submission
- CD ~/user2
- git clone [email protected]:repo/sample.git
- CD sample
- echo "Hello git!" > User2.txt
- git add user2.txt
- Git commit-m "User2 commit"
- Git push Origin Master
- git log
"Situation 1" User 1 submitted
- CD ~/user1/sample
- echo "Hello git!" > User1.txt
- Git pull
- git Add.
- Git commit-m "User1 commit"
- git log--graph
User 1 also commits a commit, paying attention to the order of execution, first git pull resubmit
Git pull updates and merges from the server (merge) to the branch
"Situation 2" User 1 submitted
If you commit the resynchronization server first, or if someone commits you before you commit it, then the log will be different.
Fallback Submission
- CD ~/user1/sample
- git reset--hard head~2 (git reset--hard head^^) (git reset--hard ad64c8c)
The first fallback User1 all operations, using git reset--hard head~2, the fallback 2 times the commit, can also be used head^^, hash value (SHA1) can be used, the hash value can not be completely written, as long as you can distinguish between different submissions can be
- echo "Hello git!" > User1.txt
- git Add.
- Git commit-m "User1 commit"
- Git push Origin Master
If the most recent commit of the service is not synchronized, it is rejected for submission to the server
This is the edit interface to modify the submission instructions, use the default submission, CTRL+X exit and complete
- Git push Origin Master
- git log--graph
You can see that more than the normal submission of a merge, User 1 and User 2 in the first commit after the respective version of each to edit, each commit, and finally submitted to the server will do a merge.
"Expand"ssh settings
If a password is required for each server operation, it can be managed using the public key if the password is canceled or if you do not want to tell the other user's server the password.
- CD ~/.ssh
- Ssh-keygen
- Ssh-copy-id-i id_rsa.pub [email protected]
Generate the public key, Id_rsa is the private key, Id_rsa.pub is the public key, if it already exists, it can be used originally. The contents of the id_rsa.pub are appended to the ~/.ssh/authorzed_keys file on the server, or they can be copied to the inside manually.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Git Learning Journey (ii)-Multi-person assistance