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 Common commands and ssh Operations in git tools

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly introduces the git tool commonly used commands and ssh operation example analysis, the article is very detailed, has a certain reference value, interested friends must read it!

Git basic command

Git clone 'remote warehouse address' pulls the replacement code from the warehouse for the first time

Git pull pull the latest

Git add. Submit the code to the staging git

Commit-m "remarks" add staging area content to the local warehouse

Git push submission

Git checkout 'branch name' switches to the specified branch name

Git branch view list of local branches

Git branch-a/-all view a list of remote branches

Git remote update origin-prune updates synchronized local and remote branch lists

Git status displays the status of the working directory and the staging area

Git branch branch name (created based on the primary branch)

Git log views all submission logs of the current branch

Git log-oneline to view all submission logs of all branches (oneline, a submission message is displayed on one line)

Git reflog views all operation records of all branches (including commit records that have been deleted and reset operations)

Clear empties the git command line

Temporary storage, local warehouse, remote warehouse, local code

Pull other branches

Pull code (master): git clone address

Pull other branch codes: git checkout-b branch name origin/ remote branch name

Merge branches

First switch to the main branch: git checkout master

Merge the specified branch into the main branch: git merge branch name:

Code submission

To prevent code conflicts, push must first pull other people's code: git pull

Git add.

Git commit-m "remarks"

Git push

Version shuttle

1. Before shuttling, you must know the version number that needs to be shuttled (can be seen in the following ways):

Git log # View all submission logs of the current branch

Git log-- oneline # View all submission logs of all branches (oneline, a submission message is displayed on one line)

Git reflog # can get records of all git operations, including those before rollback (recommended)

2.git reset-hard version number version shuttle

Pay attention

1. In development, a new branch must be operated in a remote warehouse and must not be created locally.

two。 After a new branch is created in a remote warehouse, local computer development needs to switch to the new branch to send, but sometimes git branch is used.

You will find that the new branch in the remote warehouse is not seen in the local branch list.

3.。 Resolve the problems in 2:

Git remote update origin-prune updates the list of remote and local branches (showing branches that are not available locally)

4. Command summary:

Git branch-a view all local branches as well as current branches

Git remote update origin-prune updates the list of remote and local branches (showing branches that are not available locally)

Git checkout branch name toggle branch

5. Any archiving is carried out on the local server, and there is no remote code repository. Therefore, all branch switching / branch merging / code push operations must be archived by add commit first.

SSH

In the form of ssh, you can operate git commands with remote warehouses without account passwords.

Remote code hosting platforms are: github, gitee, gitllab. This chapter only demonstrates the ssh configuration of gitlab. Other platforms can be done by Baidu.

1.

two。

3.

4.ssh-keygen-t rsa-C "your.email@example.com"-b 4096

5. Enter the specified folder-> C:\ Users\ hwm.ssh

6. Enter cmd command mode:

Paste the content copied in step 4 and change the mailbox (any name)-> changes to the red underline

Note: if ssh has been configured and there are ssh files in the C:\ Users\ hwm\ .ssh directory, you cannot press enter by default when executing the command, otherwise the previous ssh configuration files will be overwritten and need to be set manually. Generate the name of the file in the screenshot red box below.

If there is no configuration file in the C:\ Users\ hwm\ .ssh directory, when the command is paused. Just enter directly and hit a total of 3 returns.

7. Open the file with the .pub suffix, select all the contents, and copy

8.

9.

ten

The above is all the contents of the article "sample Analysis of Common commands and ssh Operations of git tools". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

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

Development

Wechat

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

12
Report