02 _ create a Git repository, clone a repository, git add, git commit, git push, git pull, peer conflicts, ending solutions for different row conflicts, use of git mergetool, gitpullcommit
1. Create a Git resource library and provide cruel directory information
Command for creating git Repository: Git init-bare repository name (where-bare indicates the meaning of an empty repository) Go to E: \ software \ repository \ git \ itheima28, as shown below: Hooks: submit some script files Info: stores personal information and configuration information. Objects: All data storage locations Refs: git pointer information, which records the modified information. Config: Core configuration information Description: description HEAD: The Branch Information to store. |
2. Use the database created above to enter E: \ git \ developer \ user1
3. clone the resource in the user folder.
Gitclone <repository directory>/g/software/repository/git/itheima <user directory>.
Note: The user directory must be empty during clone.
Go to the user1 directory
E: \ software \ developer \ user1 \. git \ objects folder where data is stored locally
4. Create a file in E: \ software \ developer \ user1 \ and upload the file to the repository.
View the status of the repository file under E: \ software \ developer \ user1
Use git add to include files in version control and use git commit for submission.
5. Push files to a remote Repository
The above commit process knowledge submits the content to the local database. To push the file to a remote repository, You need to execute the git push command.
Push to the remote shared version Repository
Git push origin master
Check whether a submission is made. Method:
1. Create user2. 2. Use the clone command to obtain the content in the remote repository. |
6. Modify the readme file under user2 and finally submit the modification process:
The vim editor is displayed during the submission process. It is used to edit log information.
Push submitted files to the remote server
7. pull the file from the remote server using the command git pull.
Modify the file in user1 again and submit
Here you need to use git add readme.txt File
To demonstrate the conflict merging process, you can view another blog:
Http://blog.csdn.net/tototuzuoquan/article/details/41398025
Demo conflict merge
(1) demonstrate different line conflicts
Avel enters user2 and modifies the readme.txt file. |
B. Go to user1 and modify the readme.txt file without git pulling. |
Conclusion: If you modify different lines in the same file, a problem occurs during git push. Git pull is mentioned above before submission At this time, you need to enter this file for modification, and then submit the modification: |
(2) merge different rows
The following is the readme.txt file in E: \ software \ developer \ user1.
Push modified file content to remote server
Delete readme.txt. orig
Summary:
There is a conflict after git pull: $ Git pull Remote: Counting objects: 5, done. Remote: Compressing objects: 100% (2/2), done. Remote: Total 3 (delta 0), reused 0 (delta 0) Unpacking objects: 100% (3/3), done. From g:/software/repository/git/itheima26 50db030 .. a04027a master-> origin/master Auto-merging readme.txt CONFLICT (content): Merge conflict in readme.txt Automatic merge failed; fix conflicts and then commit the result. Solution: 1. git mergetool After calling the above command, you will be prompted to enter the editing method and enter: beyond compare to enter the editor. 2. After editing, call git commit-a to submit all the files in the current directory to the local database. 3. git push origin master submitted to the remote database. |
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.