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

Introduction and use of git command

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article mainly explains the introduction and use of the git command. The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn the introduction and use of the git command.

The difference between git and github

Git is equivalent to client github is equivalent to server side (code hosting center) to submit code to remote server side through git client (code hosting center)

Local area network code hosting center such as gitlab

Public network code hosting centers such as github Code Cloud

Git help commands such as git help reset to see how the command is used

Git init initializes the git native library

Set signature

Git config user.name xiaozhou sets the local library user name

Git config user.email xiaozhou@qq.com sets the local library mailbox

Git config-- global user.name xiaozhou sets the global user name

Git config-- global user.email xiaozhou@qq.com sets the global mailbox

Git status to view the status of files in the local library of git

Git add filename adds local files to the staging area

Git rm-cached filename removes files from the staging area

Git commit filename submits files in temporary storage to the local library

Git commit-m "message submission information" filename

View the submission log

Git log

Multi-screen display control mode:

The space turns down the page.

B turn the page up

Q exit

Git log-- pretty=oneline display on one line

Git reflog

HEAD@ {how many steps does it take to move to the current version}

Operation based on index value [recommended]

Git reset-- hard [local index value]

Git reset-hard a6ace91

Use the ^ symbol: only backwards

Git reset-- hard head ^

Note: one ^ means one step back, and n means step back.

Use the ~ symbol: only backwards

Git reset-hard HEAD~n

Note: it means to take n steps back

In git reset

-- hard local library staging area workspace rollback to the specified version

-- mixed local libraries and staging areas are rolled back to the specified version of the workspace.

-- soft local library version rollback to the specified version staging area and workspace content unchanged

Compare file differences

Git diff [filename] such as git diff aa.txt compares files in the workspace to the staging area

Git diff [local library history] [file name] such as git diff HEAD version number aa.txt compares the files in the workspace with the local library history

Git diff compares multiple files without a file name

Git branch-v to see which branches are in total

Git branch branch name such as git branch hot_fix create branch the branch content on which branch is currently created is the same as which branch, for example, the hot_fix branch hot_fix branch content currently created on the master branch is the same as the master branch, if you currently create the hot_fix branch on the relase branch, the hot_fix branch content is the same as the relase branch content.

Git checkout branch name such as git checkout hot_fix switch branch

Git merge merges the branch names of the content, for example, to merge the hot_fix branch into master, the first step is to switch to the master branch, and the second step is to execute the merge command git merge hot_fix.

Resolving conflicts when merge merges

For example, now you want to merge the contents of the master branch into the hot_fix branch.

Conflict occurs when the files of both the hot_fix branch and the master branch are modified on the same line

> represents the content of another branch (master)

The resolution of conflicts

The first step: edit the file, delete the special symbol, that is, delete the conflict, such as

Or leave the correct content and save it.

Step 2: git add [file name] git add aa.txt

Step 3: git commit-m "log information" Note: commit must not have a specific file name at this time.

Git remote-v to see what remote code hosting center addresses are available in the current git where code can be submitted

Git remote add alias remote code hosting center address give a remote code hosting center an individual name such as git remote add oo https://github.com/xx/xxxxxx after oo represents the https://github.com/xx/xxxxxx address

Git push remote code hosting center alias branch name to push to remote code hosting center push submitted code such as git push oo master

Git clone remote code hosting center address download a branch of a remote code hosting center such as git clone https://github.com/xxx/xxxx

Github invites developers to join (if developers are not invited to join a github, developers cannot submit code to a github)

The first step is for developers to sign up for a github account.

Step 2: access the https://github.com/xxxx/xxxx/settings github address

Step three

Send the link copied in figure 2 above to the developer and click on it

Git pull remote code hosting center alias branch name pull remote code such as git pull oo master

Git pull = git fetch+git merge operation

Git fetch remote code hosting center alias branch name pulls remote code but does not merge with local branch such as git fetch oo master requires merge to local library

Play tag

Git tag lists labels

Git tag-a v1.0-m "version 1.0" create label-a followed by version number-m remarks

Git push origin v1.1 submit a local tag to the remote warehouse

Git push origin-tags submit tags to the remote warehouse-tags can submit all locally typed tags to the remote warehouse.

Git tag-d version deletes the local tag-d means deletion, followed by the name of the tag to be deleted

Git push origin: refs/tags/version removes remote tag

Thank you for your reading, the above is the content of "introduction and use of git command". After the study of this article, I believe you have a deeper understanding of the introduction and use of git command, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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

Servers

Wechat

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

12
Report