Home > Development Tools > git > Git command line operation, remote library operation, internal and external team collaboration, SSH login

Git command line operation, remote library operation, internal and external team collaboration, SSH login

coldplay.xixi
Release: 2021-03-01 09:39:44
forward
2937 people have browsed it

Git command line operation, remote library operation, internal and external team collaboration, SSH login

Recommended (free): Git Tutorial

Article Directory

  • 1. Remote library creation
    • Initialize local library
    • Create remote library
    • Create remote library locally Address alias
  • 2. Collaboration within the team
    • push push operation
    • clone clone operation
    • invitation Don’t join the team
    • pullRemote library modification pull
    • Conflict resolution during collaborative development
  • 3. Cross-team collaboration operation demonstration
  • 4. SSH login

Git command line operation, remote library operation, internal and external team collaboration, SSH login

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.
Git command line operation, remote library operation, internal and external team collaboration, SSH login

Create a remote library

Create a new repository(warehouse) on GitHub. To prevent confusion, it is also used here The name of GItHome1.

Git command line operation, remote library operation, internal and external team collaboration, SSH login
Git command line operation, remote library operation, internal and external team collaboration, SSH login

Create a remote library address alias locally

Use the git remote -v commandYou can check the current aliases; use git remote add [alias] [remote library address]You can give an alias to the remote library.

Git command line operation, remote library operation, internal and external team collaboration, SSH login

The address of the remote library can be viewed as follows:
Git command line operation, remote library operation, internal and external team collaboration, SSH login

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.
Git command line operation, remote library operation, internal and external team collaboration, SSH login
Git command line operation, remote library operation, internal and external team collaboration, SSH login

clone clone operation

Clone command: git clone [warehouse address]

  • Can completely download the remote library to the local.
  • Inherit the alias created for the remote address before push.
  • Initialize the local library.
    Git command line operation, remote library operation, internal and external team collaboration, SSH login

Invite others to join the team

Git command line operation, remote library operation, internal and external team collaboration, SSH login
After sending the invitation link to the invitee, the invitee Accept the invitation to join the team.
Git command line operation, remote library operation, internal and external team collaboration, SSH login
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.
Git command line operation, remote library operation, internal and external team collaboration, SSH login
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.

Git command line operation, remote library operation, internal and external team collaboration, SSH login

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]
    Git command line operation, remote library operation, internal and external team collaboration, SSH login
    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.
    Git command line operation, remote library operation, internal and external team collaboration, SSH login

  • Merge: git merge [remote library address alias/remote branch name]
    Merge the captured files to the local storehouse.
    Git command line operation, remote library operation, internal and external team collaboration, SSH login

  • Two-in-one command: git pull [remote library address alias] [remote branch name]
    Git command line operation, remote library operation, internal and external team collaboration, SSH login

Conflict resolution during collaborative development

  • If the modification is not based on the latest version of the GitHub remote library, it cannot be pushed and must be pushed first Pull.
  • If it enters a conflict state after pulling it down, just follow the 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.
Git command line operation, remote library operation, internal and external team collaboration, SSH login
Git command line operation, remote library operation, internal and external team collaboration, SSH login

After modifying your own remote library, initiate a Pull Request request:
Git command line operation, remote library operation, internal and external team collaboration, SSH login
Git command line operation, remote library operation, internal and external team collaboration, SSH login
Git command line operation, remote library operation, internal and external team collaboration, SSH login
Git command line operation, remote library operation, internal and external team collaboration, SSH login
Git command line operation, remote library operation, internal and external team collaboration, SSH login
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:

  • In the home directory, delete the .ssh directory.
  • Run the command to generate the .ssh key directory: ssh-keygen -t rsa -C [GitHub username].
  • Enter the .ssh directory to view the file list, view and copy the contents of the id_rsa.pub file: cat id_rsa.pub.
  • Log in to GitHub, click user avatar→Settings→SSH and GPG, New SSH Key, and enter the copied key information.
  • Create a remote address alias in Git bashorigin_sshgit remote add origin_ssh [ssh address of the remote library]
  • Push the file for testing:git push origin_ssh master

The following is a detailed demonstration:
Git command line operation, remote library operation, internal and external team collaboration, SSH login

Git command line operation, remote library operation, internal and external team collaboration, SSH login
Use cat to view the generated id_rsa .pub file , copy the ssh code:
Git command line operation, remote library operation, internal and external team collaboration, SSH login

Git command line operation, remote library operation, internal and external team collaboration, SSH login
Git command line operation, remote library operation, internal and external team collaboration, SSH login

Git command line operation, remote library operation, internal and external team collaboration, SSH login

Git command line operation, remote library operation, internal and external team collaboration, SSH login##

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!

Related labels:
git
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template