preface

In fact, I wanted to write this article for a long time, but I think this thing is the most common, should be familiar with everyone, but in the actual work, there are still a lot of people do not know how to use Git command line, or even Git client tools are not very good at using, terrible

In fact, if this thing is only used for the development of work, there is no need to buy a book for it and research, just need to understand the principle, learn to use common commands

This article assumes that you have a certain foundation of Git, this article is to introduce Git command line, explain the function of each command

Git commits to a local repository (stage), commits to a local repository (push), and commits to a remote repository (stage)

Git is the most advanced distributed version control system in the world, designed to solve the problem of multi-person collaboration and multiple changes

Most smoothly submitted

Git is the most advanced distributed version control system in the world (not one of them).

Git is the most advanced distributed version control system in the world (not one of them).

Configure and create repositories, branch commands, tag commands, modify and commit, undo, view history,

Configure and create version libraries

Git config –list

Git config –global user.name “name”

Git config –global user.email

Check out the warehouse: git clone git://github.com/jquery/jquery.git

Git remote -v

Git remote add [name] [url]

Git remote rm [name]

Git pull [remoteName] localBranchName

Git push [remoteName] localBranchName

Branch command

To view all remote branches: git branch -r

View all local branches: Git Branch

To view all branches: git branch -a

Git branch [name] You need to manually switch branches

Git push origin [name]

Git checkout -b [name]

Git checkout [name]

Git branch -d/ -d [name] -d is used to forcibly delete local branches. -d can only delete branches that have been merged

Git push origin –delete [name]

Force override local code: git fetch –all && git reset –hard origin && git pull

Git merge [name] merges the name branch into the current branch

Git status: git status

The tag command

Check the version: git tag

Git tag [name]

Git tag -d [name]

To check the remote version, run git tag -r

Git push origin [name]

Git push origin –delete [name]

Merge remote repository tags locally: git pull origin –tags

Upload local tags to remote repositories: Git push Origin –tags

Git tag -a [name] -m ‘message’ git tag -a [name] -m ‘message’

Modify and commit code

Git status

Check out git diff

Git add [file]

Add all the modified files to the staging area: git add.

Git mv [old] [new]

Git rm [file]

Git commit -m ‘message’

Modify the last commit: git commit –amend

Git origin [name]

Git merge [name] merges the name branch into the current branch

Revocation of the code

Git reset HEAD xxx.java

Git reset HEAD undo add for all files

Git reset –hard HEAD

Git reset [–mixed –soft –hard] commitID

— Mixed means to undo git add and git commit and keep the editor code.

–soft: revoke git commit, do not undo git add, and keep the editor code.

The –hard parameter is a very violent one. If you decide to use the –hard parameter, you should have decided to discard all the code you changed

Git reset commitID/git revert commitID **

Reset returns to a Commit. This Commit and previous commits are retained, but subsequent changes are returned to the staging area

Revert undoes a Commit by creating a new Commit. All previous commits are kept

Check the information

View the version and history of the current branch: git log

Git log –stat displays the commit history and the files that changed each commit: git log –stat

Git log -s [keyword]

Git log –follow [file]

Git log-5 –pretty –oneline shows the last five commits: git log-5 — Pretty –oneline

Git shortlog-sn displays all submitted users, sorted by the number of submitted users

Git blame [file] : git blame [file]

Display the difference between staging and workspace: git diff

Displays the most recent commits for the current branch: git reflog

Create a new Git code base: Git init

Git status: git status

Remote synchronization

Git fetch [remote]

Git remote -v displays all remote repositories: git remote -v

Git remote show [remote]

Git remote add [shortname] [url] git remote add [shortname]

Git push [remote] [branch]

Git push [remote] –force

Git push [remote] –all

O praise

Well, that’s all. I’m your captain and your learning partner forever. If you feel this article is helpful to you, click follow me

I hope to be able to make a living by writing articles one day, and I am still honing my skills. This time may take many years. Thank you for being my original reader and communicator. Please believe that as long as you give me a love, I will eventually return you a page of love.

Thank you again for reading here, I will continue to update the technical articles and some records of the soul of life articles, if you feel good, feel something, please like, pay attention to, share three

Oh, right! The subsequent update of the article I will be put here in time, welcome to click to watch, are dry articles ah, suggest collection, at any time to check

Github.com/DayuMM2021/…

Recommended reading

● The interviewer asked me: Are you sure that using BigDecimal is accurate?

● This GitHub address smells good

● Getting started with message queues

● What is RocketMQ