Git Development and Operation Manual

Git Complete

Summary of Git commonly used commands

Summary of Git commonly used commands

Basic git commands

Git basics-the use of remote warehouses

Git download, installation and environment configuration

(Detailed) Using git tutorial in IDEA

IDEA Git version management code merge

How git merges the branch code into the master branch

Git installation and configuration tutorial

Git push

gitlab creates and accepts merge requests Merge Requests

IDEA Cherry-Pick  code changes merge certain submissions, then Cherry pick can be used

git config:

View local git configuration

git config --list

Set username

git config --global user.name "yourname"

Set up user mailbox

git config --global user.email [email protected] 

Generate ssh 

ssh-keygen -t rsa -C "[email protected]"  

Follow the prompts and press Enter three times to generate the ssh key. ~/.ssh/id_rsa.pub Obtain your public key by viewing the  contents of the file

cat ~/.ssh/id_rsa.pub

Copy the generated ssh key, add the generated public key to the warehouse

After adding, enter in the terminal (Terminal)

ssh -T [email protected]

For the first use, you need to confirm and add the host to the local SSH trusted list. If the Hi XXX! You've successfully authenticated, but Gitee.com does not provide shell access. content is returned  , it proves that the addition is successful

Modify git remote url

git remote set-url origin ssh://***

 

git fall back to the historical commit version 

First use the command to find the commit id of the version to be rolled back:

git reflog 

or

git log --oneline

 Then roll back the version

git reset --hard 历史ID

Finally, force push to the remote branch:

After the local branch is rolled back, the version will lag behind the remote branch. Forced push must be used to overwrite the remote branch, otherwise it cannot be pushed to the remote branch.

Note that it is not necessarily the master branch, depending on the situation of your own development branch

git push -f origin master
git push -f origin master:refs/for/master

 

 

git delete files that have been pushed 

When we need to delete 暂存区or 分支upload a file, and the workspace does not need this file, we can use

git rm -r file_path
git commit -m 'delete somefile'

When we need to delete 暂存区or 分支upload a file, but need to use it locally, but we don't want this file to be version controlled, we can use it

git rm -r --cached file_path
git commit -m 'delete remote somefile'

Finally push push

Guess you like

Origin blog.csdn.net/xiangwang2016/article/details/107634475