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

What are the basic operation commands commonly used in Git

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

This article is to share with you about the basic operating commands commonly used in Git. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Git common commands

1. Commonly used

$git remote add origin git@github.com:yeszao/dofiler.git # configure remote git version library $git pull origin master # download code and quickly merge $git push origin master # upload code and quickly merge $git fetch origin # get the replacement code from the remote library $git branch # display all branches $git checkout master # switch to master branch $git checkout-b dev # create and switch to the dev branch $git commit-m "first version" # submit $git status # View status $git log # View submission History $ Git config-- global core.editor vim # sets the default editor to vim (git defaults to nano) $git config core.ignorecase false # sets case-sensitive $git config-- global user.name "YOUR NAME" # sets user name $git config-- global user.email "YOUR EMAIL ADDRESS" # sets mailbox

two。 Alias alias

$git config-- global alias.br= "branch" # create / view local branch $git config-- global alias.co= "checkout" # switch branch $git config-- global alias.cb= "checkout-b" # create and switch to a new branch $git config-- global alias.cm= "commit-m" # submit $git config-- global Alias.st= "status" # View status $git config-global alias.pullm= "pull origin master" # pull branch $git config-global alias.pushm= "push origin master" # submit branch $git config-global alias.log= "git log-oneline-graph-decorate-color=always" # single line, Color display record $git config-global alias.logg= "git log-graph-all-format=format:'%C (bold blue)% h% C (reset) -% C (bold green)% C (reset)% C (white)% s% C (reset)% C (bold white) -% an%C (reset)% C (bold yellow)% d% C (reset)'- abbrev-commit-- date=relative" # complex display

3. Create a version library

$git clone # Clone the remote version library $git init # initialize the local version library

4. Modify and submit

$git status # View status $git diff # View changes $git add. # tracking all changed files $git add # tracking specified files $git mv # file renaming $git rm # deleting files $git rm-- cached # stop tracking files but not deleting $git commit-m "commit message" # submit all updated files $git commit-amend # modify the last submission

5. View history

$git log # View submission history $git log-p # View the submission history of the specified file $git blame # View the submission history of the specified file as a list

6. Revocation

$git reset-- hard HEAD # undo the changes to all uncommitted files in the working directory $git reset-- hard # undo to a specific version $git checkout HEAD # undo the changes to the specified uncommitted file $git checkout-- # same as the previous command $git revert # undo the specified submission branch and tag

7. Branches and labels

$git branch # shows all local branches $git checkout # switches to the specified branch or label $git branch # creates a new branch $git branch-d # deletes the local branch $git tag # lists all local tags $git tag # based on the latest submission Create the tag $git tag-a "v1.0"-m "some instructions" #-a specify the tag name -m specify label description $git tag-d # remove tag $git checkout dev # merge specific commit to $git cherry-pick 62ecb3 on dev branch

8. Merger and derivative

$git merge # merge the specified branch to the current branch $git merge-- abort # cancel the current merge, reconstruct the pre-merge state $git merge dev-Xtheirs # to merge the dev branch to the current branch, if there is a conflict, the dev branch prevails $git rebase # derives the specified branch to the current branch

9. Remote operation

$git remote-v # View remote version library information $git remote show # View specified remote version library information $git remote add # add remote version library $git remote remove # delete specified remote version library $git fetch # get replacement code from remote library $git pull # download code and quickly merge $git Push # upload Code and Quick merge $git push: # Delete remote branches or tags $git push-- tags # upload all tags

10. Packing

$git archive-- format=zip-- output.. / file.zip master # package the master branch into a file.zip file, save it in a higher-level directory $git archive-- format=zip-- output.. / v1.2.zip v1.2 # packaged v1.2 tag file, and save it in a higher-level directory v1.2.zip file, $git archive-- format=zip v1.2 >.. / v1.2.zip # acts as the previous command

11. Global and local configuration

The global configuration is saved in: $Home/.gitconfig local warehouse configuration is saved in: .git/config

twelve。 Merge remote and local

$git init # initializes the local code warehouse $git add. # add local code $git commit-m "add local source" # submit local code $git pull origin master # download remote code $git merge master # merge master branch $git push-u origin master # upload code thank you for reading! This is the end of this article on "what are the basic operating commands commonly used in Git?". 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, you can 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