Git uses command skills

foreword

When we use git, we will see the following records after submitting:
insert image description here

It is often encountered that after submitting, the name of the author is inconsistent with the name set by myself, how to change it but I don’t know

View Submitted Usernames

Let's first take a look at how to view the user name in our git, the command is as follows:

git config user.name

Use this command to see what the user name we set in git is.

Change Submit Username

Through the following command, we can change the username in our git, and replace the username in that with our own name that needs to be displayed!

git config --global user.name "username"

View the diff of the file

1. Compare the difference between the current file and the file in the temporary storage area
git diff

2. Compare the difference between the two submissions
git diff


3. Compare git diff between two branches ...

4. Compare the difference between the temporary storage area and the version library
git diff --staged

5. Compare the difference between the temporary storage area and the version library
git diff --cached

6. Only compare statistics
git diff --stat

View commit history

1. View each submission record of the file
git log git log

2. View the diff
git log -p of each detailed modification


3. View the diff git log -p -2 of the last two detailed modifications

4. View the submission statistics
git log --stat

Git local branch management

View, switch, create and delete branches

1. View the remote branch
git br -r

2. Create a new branch
git br <new_branch>

3. View the final submission information of each branch
git br -v

4. View the branch
git br --merged that has been merged into the current branch

5. View the branch
git br --no-merged that has not been merged into the current branch

6. Switch to a certain branch
git co

7. Create a new branch and switch to
git co -b <new_branch>

8. Create a new new_branch based on branch
git co -b <new_branch>

9. Check out a certain historical submission record, but there is no branch information. Switching to other branches will automatically delete
git co $id

10. Check out a historical submission record and create a branch
git co $id -b <new_branch>

11. Delete a branch
git br -d

12. Forcibly delete a certain branch (it needs to be forced when the unmerged branch is deleted)
git br -D

Welcome everyone to click on the card below to pay attention to "coder trainees"

Guess you like

Origin blog.csdn.net/ybb_ymm/article/details/131372399