Recommended (free): Git Tutorial
Article Directory
1. Remote library creation
Initialize local Library
Create a local library named GitHome1
, use the git init command
to initialize, and create the jiuyangzhenjing.txt file
, add it to the staging area and submit it to the local library.
Create a remote library
Create a new repository(warehouse)
on GitHub. To prevent confusion, it is also used here The name of GItHome1
.
Create a remote library address alias locally
Use the git remote -v command
You can check the current aliases; use git remote add [alias] [remote library address]
You can give an alias to the remote library.
The address of the remote library can be viewed as follows:
2. Collaboration within the team
push push operation
Push command: git push [remote library alias] branch name
After entering the command , enter your GitHub account password on the pop-up page and it will be automatically transferred to the remote library.
clone clone operation
Clone command: git clone [warehouse address]
Invite others to join the team
After sending the invitation link to the invitee, the invitee Accept the invitation to join the team.
At this time, after the invitee clones the file to his local library for modification, he can upload it to the remote library GitHub through the push command.
When the invitee uses the push command to push, the login account and password are not prompted. This is because the credential manager on Windows remembers the account password. When you need to change another account, you can Delete this.
pull pull remote library modifications
pull command = fetch command merge command; when the modifications are made It is relatively simple. When conflicts are not likely to occur, just use the pull command. Otherwise, you can use fetch to grab it and take a look, and then use merge to merge.
Fetch (read operation): git fetch [remote library address alias] [remote branch name]
The fetch fetch operation is only The read operation will not change the files in the workspace. If you want to see the captured files at this time, you can switch the branch to Remote library address alias/remote branch name
, and then use cat to view it.
Merge: git merge [remote library address alias/remote branch name]
Merge the captured files to the local storehouse.
Two-in-one command: git pull [remote library address alias] [remote branch name]
Conflict resolution during collaborative development
Branch conflict resolution
operation to resolve it. 3. Cross-team collaboration operation demonstration
People outside the team will find the Fork
button according to the project address and click it, thenclone clone
the project to the local, and push
to your own remote library after modification.
After modifying your own remote library, initiate a Pull Request
request:
At this time, internal team members use git pull [remote library alias] [remote branch name]
to pull the project locally. This ends the entire process of cross-team collaboration.
4. SSH login
Windows10 saves the account and password for us in Credential Management
, but if it is something else, there is no credential management If the system operates based on the HTTP address and the system does not remember the user name and password, you need to log in and provide the user name and password every time you push. You can use SSH to avoid entering the account number and password every time you log in.
To summarize, there are the following steps:
.ssh
directory. ssh-keygen -t rsa -C [GitHub username]
. .ssh
directory to view the file list, view and copy the contents of the id_rsa.pub
file: cat id_rsa.pub
. origin_ssh
:git remote add origin_ssh [ssh address of the remote library]
git push origin_ssh master
The following is a detailed demonstration:
Use cat to view the generated id_rsa .pub file
, copy the ssh code:
##
The above is the detailed content of Git command line operation, remote library operation, internal and external team collaboration, SSH login. For more information, please follow other related articles on the PHP Chinese website!