This is the 20th day of my participation in the August Text Challenge.More challenges in August
Addresses for downloading installation packages for each platform
Windows platform download address
Domestic mirror
Novice tutorial
Git configuration
Configuration file (gitConfig)
#If global is not added to the global user name and email address, it is valid locally
$ git config --global user.name "A"
$ git config --global user.email [email protected]
#For the current warehouse
$ git config -e
Copy the code
View all configuration information
$ git config --list
http.postbuffer=2M
user.name=A
[email protected]
Copy the code
View a single configuration
$ git config user.name
A
Copy the code
Git Workflow
Work process:
- 1 Clone code to a local directory.
- 2 Add or modify files in local code.
- 3 If others modify the code, you can pull the code to view the latest code.
- 4. Pull down the latest code before submission. If there is any conflict, resolve it first.
- 5 Submit the code. If any problem is found in the submitted code, you can roll back, modify the problem, and submit the code again.
Git create repository
#Initialize the warehouse
git init
#Initialize the repository for the specified directory
git init fileName
#After the repository is initialized, a.git directory is generated to hold the repository operation records
#Add the README file
$ git add README
#Add files ending in.c
$ git add *.c
#Adding comments In Linux, single quotation marks are used after -m' '/ Double quotation marks are used in Windows""
$ git commit -m "Initialize the project"
Copy the code
Git clone repository
#Clone the warehouse directly to the current addressGit Clone repository address
#Clone repository to specified directoryGit Clone repository address Specifies the directory
#RocketMQ warehouse, for example https://github.com/apache/rocketmq.git
git clone https://github.com/apache/rocketmq.git D:\workspace\rocketmq
Copy the code
Git Basic Operations
graph LR A[workspace] -->|add|B(staging area) B[staging area] -->|commit|C(local repository) C[local repository] -->|checkout|A(workspace) D[remote repository] -->|fetch/clone|C(local repository) C[local repository] -->|push|D(remote repository) D[remote repository] -->|push|A(workspace)
Description:
- The workspace workspace
- Staging area Cache area
- Local repository Local repository
- Remote repository Remote repository
#Basic operationGit diff: git diff: git diff: git diff: git diff: git diff: git diff If you want to create a new version of git, you can create a new version of git. If you want to create a new version of git, you can create a new version of git. Git fetch git fetch git fetch git fetch git fetch git fetch git fetch git fetchCopy the code
Git Branch Management
#Branchname Name of the branch
git branch branchname
#Switch branch
git checkout branchname
#Merge branches Merge branches to the current branch
#The dev branch is merged into the master branch first, then the dev branch is merged into the master branch
git merge branchname
#View all local branches
git branch
#Delete the branch
git branch -d branchname
Copy the code
Git looks at the commit history
#View historical submission recordsGit log [optional]
#parameter--oneline # check the history of the commit record brief version --graph # check the history of the branch, merge --reverse # reverse display all logs --author=Xxx# check the history of the commit log --since # date before --before # before --after --after --after
#View the historical modification records of a specified file in a list
git blame <file>
Copy the code
Git label
#Create a tag (not recommended, not tag, time, creator)
git tag -a
#Create an annotated label (recommended)Git tag - a v1.0
#Append the label to the previous submission with the record code 85FCA1A2 for the submissionGit tag-a v0.985fCA1a2
#View all labelsGit tag v0.9 v1.0
#Specifying label InformationGit tag -a tagname -m
#PGP signature label commandGit tag -s tagname -mCopy the code
Git Gitee/Git Github
Creating an SSH Connection
Check whether the local key exists, and use it directly.(Check whether id_rsa and ID_rsa_pub exist in the directory \ user \ local username \. SSH on disk C)
1 Open Git Bash and run the create command
#Directly to create
ssh-keygen
#-t Specifies the type of the key. Default is the RSA key of SSH-2. -c Specifies the comment information
ssh-keygen -t rsa -C "[email protected]"
Copy the code
2 Add SSH to the version management repository
Open the ID_RSA_pub file with text, copy the contents, and add it to the Gitee repository public keyCopy the code
Basic operation
#Associated remote warehouseGit remote add Origin Specifies the remote repository address
#View remote library information
git remote -v
#Deleting remote libraries
git remote rm origin
#Associating the Gitee and Github repositories at the same time is ok, but the name of the remote repository should be different, not both origin
git remote add github [email protected]:xxx
git remote add gitee [email protected]:xxx
#Push code to distinguish between remote repository names
git push github master
git push gitee master
Copy the code