git manual - simple and practical

common commands

Create warehouse

git init Initialize warehouse
git clone Copy a remote warehouse, that is, download a project.

 Submit and modify

git add Add files to repository
git status View the current state of the repository, showing changed files.
git diff Compare the difference between files, that is, the difference between the temporary storage area and the work area.
git commit Submit the staging area to the local warehouse.
git reset Fallback version.
git rm Delete workspace files.
git mv Move or rename workspace files.

commit log

git log View commit history
git blame View the historical modification records of the specified file in the form of a list

remote operation 

git remote Remote Warehouse Operations
git fetch Fetch code base from remote
git pull Download remote code and merge
git push Upload remote code and merge

Install Git software
Go here to download https://npm.taobao.org/mirrors/git-for-windows/, the official website can be downloaded to your doubtful life, just choose the version you need to download and install;
after installation, you can open it directly Use the command to enter your project; or in your project directory, right click and select Git Bash Here to open

 insert image description here

 Open it and configure your user name and mailbox. This is a global configuration, which will write all the warehouses on this computer. Of course, you can set different ones for a certain warehouse.

 

git config --global user.name "名字"
git config --global user.email "邮箱"

first upload

The installation process goes

git init

Initialize a new local warehouse, which generates a hidden folder named .git in the working directory

git add .

 Don't forget the spaces and dots. A dot means adding all the files in the folder to the local warehouse. You can also specify a file such as:git add index.html

git commit -m "1.0版本"

 Associate remote warehouse

git remote add origin 刚刚的地址

Commit the file to the repository

git push -u origin master

Push all the contents of the local library to the remote library

the branch

Upload an independent branch
(for example, the code is a DOWNLOAD ZIP file directly from the project, which is independent of the original MASTER branch)

1. git init (in the local project directory)

2、git add .

3. git commit -m "luyang" ("luyang" is the branch name)

4. git branch luyang (create branch)

5. git checkout luyang (switch branch)

6. git remote add origin http://192.168.36.10:10080/quantum_rng_testing/nist ("quantum_rng_testing/nist" is the directory of the project, this time without the .git suffix)

7. git push origin luyang (upload the branch)

Note: If prompted "please tell me who you are"

The config file in the .git directory, add at the end

[user]
name = xxxx
email = [email protected]

This creates a branch and uploads
the merged

git merge ginger

 would be like this:
insert image description here

 

Then go to Code Cloud to see if the merge is successful, if not, execute this command

git push --force origin master

Will appear:

insert image description here

 

Then go to Code Cloud to see if the merger is successful

delete branch

After the merge, the branch can be deleted, which can be deleted in the branch management of Code Cloud;
orgit branch -d 分支名称

Guess you like

Origin blog.csdn.net/xybhua/article/details/130137700