About git basics

Insert picture description here
When we want to use git, there are two ways to create a warehouse.
$ git clone [url]
clone a remote warehouse
$ git init to
create a local warehouse

For a local warehouse, if you want to upload to a remote, you also need to add a remote warehouse.
$ git remote add origin [url]
Associate the local warehouse and the remote warehouse

git add [file1] [file2]… or git add.
Add the file to the staging area.
git commit -m "message" to
submit
Insert picture description here

The .gitignore file stores some file matching rules, and the matched files will not be added to the temporary storage area when we execute "git add.", so as to avoid submitting certain files to git by mistake. https://github.com/ github/gitignore has templates in some languages ​​for reference.
readme.txt is used to briefly introduce the project.

 上面2个文件基本是每个git项目必备的.下面有些可选的文件.

The CHANGELOG file is necessary for frequently updated and iterative projects. The
LICENSE file is used for open source projects to declare open source agreements. The
CONTRIBUTING.md file is used to guide others to contribute code. In
principle, we do not directly develop on the master branch, so we need to create new ones Branches are used for development. The command
$ git checkout -b mybranch is
equivalent to the two commands git branch mybranch and git checkout mybranch. During the
functional development process, you can submit code regularly, or you can submit by module, but it is best not to have too long intervals, which will cause Many changes have been submitted at one time, which is not convenient to check. After the
function development is completed and the function is confirmed to be correct, you can merge the branch to the master branch. There are two commonly used methods, "git merge" and "git rebase". The specific differences are described in detail in section 2 .
the combined branch can no longer needed to remove the branch.
$ git branch -d mybranch
if mybranch has been pushed to the remote repository, but also delete the remote branch.
$ git the push Origin --delete mybranch

Next, you can push the modified branch to the remote warehouse.
$ git push origin develop
Here, if the develop of the remote warehouse is also modified, the submission will fail because of conflicts.

Insert picture description here
At this time, you need to synchronize the remote branch to the local first and then push. The difference between
$ git pull or git pull --rebase
is the same as the difference between git merge and git rebase, which will be mentioned in the second section. Here I prefer git pull --rebase.

When the project is developed to a certain level, you can develop a version and mark it with a tag.
$ git tag v1.0 #only tag
$ git tag -a v1.0 -m “my version 1.0” #Include additional information
if you want to If you push tags to a remote location, you can use the following command.
$ git push origin v1.0 #push a single tag
$ git push origin --tags #push all local tags

Guess you like

Origin blog.csdn.net/qq_35037684/article/details/114754432