Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example analysis of Git command line operation, remote library operation, collaboration inside and outside the team, SSH login

2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article will explain in detail the example analysis of Git command line operation, remote library operation, cooperation inside and outside the team, and SSH login. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.

I. remote library creation

Initialize the local library

Create a local library called GitHome1, initialize it with the git init command, and after you create the jiuyangzhenjing.txt file, add it to the staging area and commit it to the local library.

Create a remote library

Create a new repository (repository) on GitHub. To prevent confusion, the name GItHome1 is also used here.

Create a remote library address alias locally

Use the git remote-v command to see which aliases are currently available; use git remote add [alias] [remote library address] to alias the remote library.

The address of the remote library can be viewed as follows:

Second, cooperation 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]

The remote library can be downloaded to the local area.

The alias given to the remote address before inheriting push.

Initialize the local library.

Invite not to join the team.

After sending the invitation link to the invitee, the invitee accepts the invitation and can join the team.

At this point, the invitees can upload the file clone to their local library for modification, and then 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, because the credential manager on windows remembers the account password, which can be deleted when another account needs to be changed.

Pull the modification of pull remote library

Pull command = fetch command + merge command; when the changes are simple and not easy to conflict, you can use the pull command, otherwise you can use fetch to grab it and have a look, and then use merge to merge.

Grab (read operation): git fetch [remote library address alias] [remote branch name]

The fetch crawl operation is read-only and will not change the files in the workspace. If you want to see the captured files, you can switch to the remote database address alias / remote branch name, and then check it with cat.

Merge: git merge [remote base address alias / remote branch name]

Merge the crawled files into the local warehouse.

Two-in-one command: git pull [remote library address alias] [remote branch name]

Conflict Resolution in Collaborative Development

If the changes are not based on the latest version of the GitHub remote library, they cannot be pushed and must be pulled first.

If you enter the conflict state after pulling it down, you can solve it according to the branch conflict resolution operation.

Third, demonstration of cross-team collaborative operation

People outside the team find the Fork button according to the project address and click it, then clone clones the project locally, and the modified push pushes it to their remote library.

After the modification of your remote library, initiate a Pull Request request:

At this point, team insiders use git pull [remote library alias] [remote branch name] to pull the project locally, ending the whole process of cross-team collaboration.

IV. SSH login

Windows10 saves the account and password for us in the place of credential management, but if it is another system that does not have credential management, the system does not remember the user name and password when operating based on the Http address, so you need to log in to provide the user name and password every time push. You can use SSH to avoid entering the account and password every time you log in.

To sum up, 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 user name].

Go to the .ssh directory to view the list of files, view and copy the contents of the id_rsa.pub file: cat id_rsa.pub.

Log in to GitHub, click the user profile → Settings → SSH and GPG,New SSH Key, and enter the copied key information.

Create a remote address alias origin_ssh:git remote add origin_ssh in Git bash [ssh address of the remote library]

Push files for testing: git push origin_ssh master

The following is a detailed demonstration:

Use cat to view the generated id_rsa.pub file and copy the ssh code:

This is the end of this article on "Git command line operation, remote library operation, cooperation within and outside the team, example analysis of SSH login". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it out for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report