Git common operations (based on TortoiseGit)

basic operation

tip: It is best to operate on git in the warehouse, that is, under the same level directory as .git

  1. Create a local warehouse
    insert image description here
  2. Submit Commit (submit to local warehouse)
    insert image description here
  3. Push push (push the local warehouse to the remote warehouse)
    tip: If the remote warehouse version is newer than ours, the push will not fail, and you need to pull it first
    insert image description here
  4. Pull pull (pull from remote warehouse to local warehouse)
    insert image description here
  5. create branch
    tip: Push the branch of the local warehouse to the remote warehouse, and a new branch will be created in the remote warehouse
    insert image description here
  6. switch branch
    insert image description here
  7. Merge branch
    tip: switch to the main branch first
    insert image description here
  8. delete branch
    insert image description here

advanced

1. Ignore file

It can be selected when creating the library, or it can be used through the git command line: touch .gitignore command
insert image description here

2. Conflict resolution when merging

The reason for the conflict:
the two merged branches have modified the same file and location
method 1:Manual fix
insert image description here
Commit:
insert image description here
Method Two: Use the git little turtle tool
insert image description here

3. Submodules

3.1 Adding submodules to the warehouse

insert image description here
insert image description here

3.2 Cloning a repository with submodules

When cloning a warehouse with submodules, recursive needs to be checked, otherwise the submodules cannot be pulled
insert image description here

3.3 Committing and pushing a repository with submodules

When there is a change in the submodule, it is necessary to submit and push to the submodule warehouse first, and then submit and push to the main warehouse

4. Version rollback

insert image description here
insert image description here

5. Delete test files that are not included in version management

in the commit

Summary at work (based on TortoiseGit)

1.Pull and Fetch

Pull = Fetch + Merge
Pull will merge the remote code with the local when pulling the remote code, so you can also do this when you need to merge the code of other branches
insert image description here

Guess you like

Origin blog.csdn.net/weixin_45136016/article/details/126424731