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

12 commonly used commands in git

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

Share

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

This article mainly introduces 12 commonly used commands in git, which can be used for reference by interested friends. I hope you will gain a lot after reading this article.

1.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 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 dev branch git commit-m "first version" # submit git status # View status git log # View submission History git config-global core.editor vim # set the default editor to vim (git defaults to nano) git config core.ignorecase false # set case-sensitive git config-global user.name "YOUR NAME" # set user name git config-- global user.email "YOUR EMAIL ADDRESS" # set 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 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 change content git add. # track all changed files git add # track specified files git mv # file renamed git rm # delete file git rm-- cached # stop tracking files but do not delete 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 a specified file git blame # view the submission history of a specified file as a list

6. Revocation

Git reset-- hard HEAD # undo changes to all uncommitted files in the working directory git reset-- hard # undo to a specific version of git checkout HEAD # undo changes to specified uncommitted files git checkout-- # same as the previous command git revert # undo specified submission branches and tags

7. Branches and labels

Git branch # shows all local branches git checkout # switches to the specified branch or tag git branch # creates a new branch git branch-d # deletes the local branch git tag # lists all local tags git tag # creates a tag git tag based on the latest submission -a "v1.0"-m "some instructions" #-a specifies the label name -m specify label description git tag-d # Delete label 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, git rebase # merges 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 code from remote library git pull # download code and quickly merge git push # Upload code and quickly 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 at: $Home/.gitconfig

The 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 article carefully, I hope the article "12 Common commands in git" shared by the editor will be helpful to you At the same time, I also hope that you will support and pay attention to the industry information channel, and more related knowledge is waiting for you to learn!

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