[Git\GitHub\GitLab study notes] Version Control Git Video Tutorial Complete Works (62P) | 6 hours from entry to master (P27-P41)

table of Contents

  1. P27-Git Basic Principles-Introduction to Hash Algorithm
  2. P28-GIt version data management mechanism
  3. P33-Initialize the local library in order to test remote interaction
  4. P34-Create a remote warehouse
  5. P35-Create remote library address alias locally
  6. P40- conflict resolution during collaborative development
  7. P41-Cross-team collaboration operation demonstration

P27-Git Basic Principles-Introduction to Hash Algorithm

Insert picture description here
Insert picture description here

P28-Git version data management mechanism

SVN: It is an incremental version control tool.
Save the increments and stitch together to get the final file when needed.
Insert picture description here
Git: Based on the idea of ​​snapshots, for files that have not been changed, use a pointer to point to the last saved file
Insert picture description here

Git file management mechanism details

Git commit object

P33-Initialize the local library in order to test remote interaction

mkdir huashan	#创建华山文件夹
cd huashan		#进入华山文件夹
git init		#初始化
vi huashanjianfa.txt

Insert picture description here

git add huashanjianfa.txt
git commit -m "test github" huashanjianfa.txt
#至此,本地库这边准备就绪

Insert picture description here

P34-Create a remote warehouse

github:http://github.com/
Insert picture description here
Click create respository to create a remote warehouse. After the creation is complete, the following information will pop up.
Insert picture description here

P35-Create remote library address alias locally

git remote -v #查看地址别名
git remote add origin[origin是地址别名] addr

Insert picture description here

P36-Push operation

Push the contents of the local warehouse to the remote warehouse

git push [连接别名/连接本身] [分支名]
git push origin master

First jump out of this page and enter your github account password. If you don’t have a github account, use the github official website to register. P33-34
Insert picture description here
Insert picture description here
Insert picture description here
Refresh the remote warehouse connection just established to see the content we just pushed huashanjianfa.txt
Insert picture description here

P37-Clone operation

Insert picture description here
clone:

  • Command: git clone [link/address of remote library to be cloned]
git clone https://github.com/atguigu2018ybuq/huashan.git
cd huashan

Insert picture description here
Insert picture description here

P38-Invite Linghu Chong to join the team members

Linghuchong modified huashanjianfa.txt and submitted the file to the local repository in an attempt to push it further to the remote warehouse, but failed and prompted an error message because the warehouse owner has not invited Linghuchong to join the team.
The warehouse owner sends an invitation to Linghuchong to join the team, and after Linghuchong agrees, the push operation can be carried out, otherwise it can only be cloned.

vi huashanjianfa.txt
git add huashanjianfa.txt
git commit -m "test push" huashanjianfa.txt
git push origin master

Insert picture description here
How to invite collaborators?
1. The warehouse owner enters the warehouse interface corresponding to github, clicks settings, as shown in the figure below
Insert picture description here
2. Clicks collaborators, enters the other party's GitHub account in the input box, selects the user, clicks add collaborator
Insert picture description here
3. Copy the invitation link and send it to the other party
Insert picture description here
4 , The other party logs in to the GitHub account, clicks on your collaboration invitation link, and clicks to join.
Insert picture description here
5. Linghuchong becomes a team member
6. Linghuchong can successfully push
Insert picture description here
[Note] When performing two account switching tests on the same machine, you need to go to the credential manager of the control panel to delete the previously remembered password.
Insert picture description here

P39-Remote library modification pull

  • pull = fetch + merge
  • git fetch [remote library address alias] [remote library branch name]

fetch only downloads the remote content to the local, but does not modify the remote content

  • git merge[remote library address alias/remote library branch name]
    [fetch+merge]
git fetch origin master
cat huashanjianfa.txt #读取的还是本地的huashanjianfa.txt文件,而不是fetch下来的文件
git checkout origin/master #切换到该目录下 查看远程仓库fetch下来的huashanjianfa.txt文件
cat huashanjianfa.txt 	#这次检查的fetch下来的远程仓库的最新内容,检擦没有问题之后再与本地的文件进行合并操作
git checkout master		#切换回本地仓库
git merge orgin/master	#将刚刚fetch下来的内容进行合并

Insert picture description here
Insert picture description here
What are the benefits of separating fetch and merge here?
When the operation is more complicated, you can temporarily not merge the local files. You can use fetch to download the files in the remote library to ensure that they are correct, and then merge the files in the remote library with the local files.
Insert picture description here
The following demonstrates the pull operation
Insert picture description here
Insert picture description here

P40- conflict resolution during collaborative development

Conflicts are easy to occur during teamwork. Two people modify the same file and the same location. When one person pushes to the remote warehouse first, the other person pushes the conflict and the push fails. At this time, you need to download the code first. Come down, look at the conflict and resolve the conflict.
Yue Buqun modifies the file and pushes it to the remote library.

vi huashanjianfa.txt
git commit -m "edit by ybuq" huanshanjianfa.txt
git push origin master

Insert picture description here
Insert picture description here
At the same time, Linghu Chong also revised the document

vi huashanjianfa.txt
git commit -m "test conflit" huashanjianfa.txt
git push origin master #发生冲突

Insert picture description here
The file version modified by Linghuchong was one version behind the remote repository. It was a modification based on the old version, but he didn't know this. When he pushed the modified file to the remote repository, it failed.
Insert picture description here
To pull the latest data again:

git pull origin master

Insert picture description here
The following is to resolve the conflict, delete special symbols, and change the content of the conflict to what you need (this content was introduced in the previous blog of this series)

git add huashanjianfa.txt
git commit -m "resolve confict" #注意这个时候对于解决冲突的提交 是不加文件名的提交
git status #查看状态
git push origin master	#推送到远程仓库

Insert picture description here
Insert picture description here

Conflict resolution

Key points:

  • If the modification is not based on the latest version of the GitHub remote library, it cannot be pushed and must be pulled first.
  • After pulling it down, if it enters the conflict state, just follow the "branch conflict resolution" operation to resolve it.

P41-Cross-team collaborative operation demonstration-Fork-pull request

Yue Buqun asked Linghuchong to develop the Sunflower Collection, but Linghuchong would not ask Dongfang Undefeated for help, but Dongfang Unbeaten was the CEO of Sun Moon Shenjiao Technology Group and could not move to Huashan, so Linghu Chong asked him to fork the Huashan project to the local area. You can make changes locally, and then pull the request after completion. After the boss Yue Buqun has reviewed it, you can merge after the review is passed.

#fork
git clone [东方不败fork之后的项目链接] #将该项目克隆到本地
ls -lA #展示当前目录下的所有文件
cd huashan
ls -lA
vi huashanjianfa.txt
git commit -m "kuihua" huashanjianfa.txt
git push origin master
#到东方不败的GitHub上面查看文件是否更新
#下面进行pull request 操作

Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Unassailable work has been completed so far, the next operate Yue Buqun
Insert picture description here
Insert picture description here
Insert picture description here
after clicking, go to the following page
Insert picture description here
two pages can talk again
Insert picture description here
after the file for approval, return to the dialog box, the following have a Merge pull request button
Insert picture description here
Insert picture description here
after clicking Fill in the information, which is equivalent to the log information
Insert picture description here
. Pull the modification of the remote library to the local. So far, the remote collaboration function is over
Insert picture description here
. You need to enter the user name and password every time you log in using the http method. SSH password-free login saves a lot of trouble.

P42-SSH password-free login

See next blog

Guess you like

Origin blog.csdn.net/kz_java/article/details/114603929