This is the 14th day of my participation in the August More Text Challenge

Git configuration

  • Git config –global user.name “username” git config –global user.name “username

  • Git config –global user.email git config –global user.email Git config –local user.email can be used to configure the mailbox for each project

  • Add remote repositories to your project. Each project can have more than one remote repository. Use Git pull repo1 to pull and commit the project separately

  • SSH -keygen -t rsa -c “[email protected]” -f ~/. SSH/key name To generate keys, the mailbox will use commit statistics, you can generate multiple for different libraries

  • Add a Git public key to the repository

  • Git push –set-upstream Remote repository name The local branch name pushes the local branch to the remote repository and does not need to be specified

  • Git config –global –list shows the configuration

Contents of the config file

# gitee
Host gitee.com
HostName gitee.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/gitee_id_rsa

# githubHost github.com HostName github.com PreferredAuthentications publickey IdentityFile ~/. SSH/Key name# github111Host github.com HostName github.com PreferredAuthentications publickey IdentityFile ~/. SSH/Key name 111You can specify key paths for multiple repositories, and the contents of the specified files will be automatically verified when pushing/pulling

Copy the code

.ssh directory structure

. SSH - | -- -- config | | - key name - the key name. Pub 111 | | - key name -- the key name 111. PubCopy the code

GIT several operations

Warehouse related commands

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 remote set-url –push [name] [newUrl]

Git pull [remoteName] [localBranchName]

Git push [remoteName] [localBranchName]

 

If you want to commit a local branch, test, to the remote repository as the master branch of the remote repository, or as another branch named test, as follows:

Git push origin test: git push origin test: git push origin test: git push origin test: git push origin testCopy the code

 

(branch) Commands related to operations

Check out the local branch: $git Branch

Check out the remote branch: $git branch -r

Run the following command to create a local branch: $git branch [name] —- Notice The new branch does not automatically switch to the current branch after it is created

$git checkout [name]

$git checkout -b [name]

$git branch -d [name] —- -d If you want to forcibly delete a branch, you can use the -d option

$git merge [name] —- Merge a branch named [name] with the current branch

$git push origin [name]

Git push Origin :heads/[name] or gitpushorigin:heads/[name] or gitpushorigin:heads/[name]