This is the fourth day of my participation in Gwen Challenge

Git configuration

Configure the Git user name

Git config --global user.name git config --global user.nameCopy the code

Configuring Git Email

git config --global user.email "email"
Copy the code

Deleting Global Configurations

git config --global --unset user.xxx
Copy the code

View Git system configuration

git config --list
Copy the code

Viewing User Configurations

cat ~/.gitconfig
Copy the code

Look at the localgitThe command history

git reflog
Copy the code

View submission History

Git log --online // The logs are displayed line by lineCopy the code

Git log --grep=" component "--onelineCopy the code

Git log --author="[email protected]Copy the code
Git log-num ex: git log-10 Indicates the last 10 commit recordsCopy the code
Git log-10 --stat // lists specific file modification statisticsCopy the code

Git Git

Submit to the staging area

git add .
Copy the code

Commit to local repository

git commit -m ''
Copy the code

Add and COMMIT are combined

Ensure that all files have been committed to the staging area, otherwise untracked files (such as new files) will not be committed to the staging area

Git commit -amCopy the code

Code submission push

Git push // pushes to the main branch by defaultCopy the code

Associated with the warehouse

Git remote add Origin Specifies the SSH address of the repositoryCopy the code

See the branch

Git branch git branch -a // Local + remoteCopy the code

The new branch

git branch branchName
Copy the code

Push the new local branch to the remote repository

Git push origin branchName git push origin branchName git push origin branchNameCopy the code

Remote branch code pull

Git pull // Default pull primary branch git pull origin branchName // Specify branch code pullCopy the code

Branch merge

git merge branchName
Copy the code

Switch branch

git checkout branchName
Copy the code

Create and switch to a new branch

git checkout -b branchName
Copy the code

Deleting a Local Branch

git branch -d branchName
Copy the code

Forcibly delete the local branch

git branch -D branchName
Copy the code

Deleting a Remote Branch

Git push origin --delete the name of the remote branchCopy the code

Push all local branches to the remote host

git push --all origin
Copy the code

Change the current branch name

git branch -m branchName
Copy the code

tagging

Git tag v1.0Copy the code

The specifiedcommit idCreate a label

Git tag 9326 e2010dcd6bbaa336610aca644995e770a15b v2.0Copy the code

Create labels with instructions

Git tag -a v3.0 -m 'description' // -a specifies the tag name -m descriptionCopy the code

View all labels

git tag
Copy the code

Push local labels

Git push origin <tagnameCopy the code

Remove the label

Git tag -d v3.0 git push origin :refs/tags/<tagname>Copy the code

A rollback operation

1. The local code has not been committed to the remote repository. Git reset --hard // Go back to the last version committed. The local code has been committed to the remote repository, and someone else in the remote repository has committed new code. Git REVERT < COMMIT_idCopy the code