Introduction to the

Git is the most advanced distributed version control system in the world. It is used to handle any project, small or large, with agility and efficiency. Collaborative development 2. Version recording 3. Conflict resolution 4. History tracing 5. Code backup 6. Version restore 7. Access management 8. Branch management 9. Code review... PDF version of the command Git command complete manual address: http://git-scm.com/docs handbook: https://www.runoob.com/manual/github-git-cheat-sheet.pdf

The difference between Git and SVN

1. Git is distributed, SVN, CVS is centralized: This is the central difference between Git and other non-distributed version control systems, such as SVN, CVS, and so on. 2. Git stores content as metadata, whereas SVN stores content as files: all resource control systems hide file metadata in a folder like.svn,.cvs, and so on. 3. The Git branch is different from the SVN branch: The branch in SVN is not special at all, it is just another directory in the repository. 4. Git does not have a global version number, while SVN does: This is by far the biggest feature that Git lacks compared to SVN. 5. Git has better content integrity than SVN: Git stores content using a SHA-1 hash algorithm. This ensures the integrity of the code content and ensures that there is less damage to the repository in the event of disk failures and network problems.

The installation of the Git

1. The command line tools: git for Windows (should write the corresponding command) download address: https://gitforwindows.org/ website slow, can use the domestic mirror: https://npm.taobao.org/mirrors/git-for-windows/ 2. Tortoisegit can be used as an extension for the Tortoisegit project on the Tortoisegit project on the Tortoisegit project on the Tortoisegit project

Configure Git Signature

Select the directory you want to store as a Git project, then right-click and select Git bash. Since Git is a distributed version control tool, we need to fill in the username and email as flags in the path of C:\ Users \ corresponding username. You can see the --global attribute in the.gitconfig file, which is shared by all Git projects. Git config --global user.name 'git config --global user.email'

Creating a repository

Enter the command in git bash to initialize the repository: git init, which will then generate a.git folder in that directory

Git related commands

2. Add a file or directory to the temporary storage area: (The file is not actually committed at this time). Git commit git commit -m git commit -m git commit -m git commit -m git commit -m git commit 4 Git log --pretty=oneline (pretty neat to show) 5. Backout history (backout to a committed version) : Git reset --hard HEAD^1 --hard HEAD~n --hard HEAD~n * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Git add) (--mix: git add) This method can restore to a previous committed version, but after the restore, the previous version will disappear. 6. Git reset --hard ID of the corresponding version (it will traverse to the version with the corresponding ID) 2) git add 3) git commit or 1) git rm-rf file (delete the file from the repository) 2) git commit To see the difference between the current file and the local repository's corresponding file: git diff head -- filename (git changes to files track changes, not the entire file) 10. Git checkout is the only workspace where the data is in git checkout. Git checkout: git checkout: git checkout: git checkout: git checkout: git checkout: git checkout: git checkout: git checkout: git checkout: Git reset --hard HEAD... git reset --hard HEAD... (Using version fallback)

Git- The relationship between workspace, staging area, and local repository

Workspace: the project's directory Local repository: a hidden directory in the workspace. Git, which is the local repository of git.

Git branch

Branch:

Git branch -v git branch -v git branch -v Git branch: branch git branch: branch git branch: branch git branch Git branch -d git branch -d git branch -d git branch -d Merge branch: merge branch (" master "); merge branch (" master "); merge branch (" master "); Disable Fast forward mode by default when merging branches: Git merge - No-FF subbranch name Fast forward and no Fast forward merge mode

Branching strategy:

8. Bug branch usage scenarios: There is a major bug in the online and master projects that needs to be fixed immediately. However, we are still working on new features on the dev branch, but we cannot commit them until they are completed. So we can save this part of the worksite: Git stash switch to the master branch, create a new branch and switch to the bug branch to solve the bug. When you have solved the bug, go back to the master branch and merge the bug branch, delete the bug branch and then go back to dev to develop the original function and resume the previous work: Git Stash List: shows the collection of workspaces in the current branch store.

Branch merge conflict

Conflict generally refers to the same file at the same location of the code, at the time of merging two versions of the warehouse, the version of the management software can not judge which one keep version, so you will be prompted the file Conflicts typically require programmers to manually correct view: git diff to resolve conflicts when branch merge conflict resolution: Switch to the directory where the conflict occurred, look at the corresponding file (you can delete it if necessary), and re-git add and git commit

Git workflow in general

1. Clone Git resources as working directories. 2. Add or modify files on cloned resources. 3. You can update the resource if someone else changes it. 4. Review your changes before you commit. 5. Submit changes. 6. After the modification is completed, if errors are found, the submission can be withdrawn and modified again and submitted. Flow chart:

About making

GitHub is a git project hosting website, which mainly provides Git-based version hosting service. Official website: https://github.com/ (global) Do not use 163 mailbox, may not receive check mail Do not use a long time, may be frozen account If the account is frozen, can enter the url: http://github.com/contact thaw for recovery

Some GitHub operations

SQL > create SSH Key ssh-keygen-t rsa-c 'mailbox'; SQL > create ssh-keygen-t rsa-c 'mailbox'; Git init git config user.name "XXX" git config user.email "XXX" git add git commit 2. 3. Create a GitHub project repository



4. Push code from Git local repository to GitHub remote repository (associate the local repository with the remote repository) 2) Push git push to remote library git push < remote code > < branch name > 1) clone git clone < remote address > < project directory name > (project directory name: Clone: name of a new directory that is used locally to clone the project (can not be filled in, by default use GitHub repository name) (Clone: name of all branches in the current address, but only show master, because there is no association. Git checkout -b dev < >/ subbranch name) 2) When you modify a file in a cloned project library and try to push it back to the remote repository, you will not have enough access to it.

After setting up the relevant things, in the corresponding clone project directory re-enter the command to commit and push to the remote library git add... git commit ... Git push origin master 3) update the project from github and type the command in the modified user's directory: Git pull < remote code > < remote branch >



Collaborative conflict

Collaborating Conflicts: When uploading or synchronizing code, because you and someone else have changed the code in the same file at the same location, the version control tool can't tell which one is the best, which reports a conflict that needs to be resolved manually by the programmer

2. Git add 3. Git commit

Third-party collaboration scenarios (modified with fork)

Third-party users fork out a corresponding library

Third-party users modify a fork file and commit synchronously





When the operation is complete, the project manager receives an email requesting synchronization and goes to GitHub to confirm the synchronization

A third party forks the target repository and modifies its contents. To synchronize the modifies into the original target repository, use a pull request.

The use of gitee

1. Configure the SSH public key in Gitee --> Settings --> SSH public key

2. Initialize the local repository 3. Create the repository on Gitee 4. Associate the local repository with the repository on Gitee



Git push-u origin branch name 6. Git clone < remote address >

GITLAB (Understanding)

GitHub official website: https://about.gitlab.com installation: (under Linux) 1. Downloads dependent on Centos7:  sudo yum install -y curl policycoreutils-python openssh-server` sudo systemctl enable sshd sudo systemctl start sshd Sudo firewall-cmd --permanent --add-service= HTTP sudo systemctl reload firewalld CentOS6:  sudo yum install -y curl policycoreutils-python openssh-server cronie sudo lokkit -s http -s ssh 2. Download and add GitLab package warehouse curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.rpm.sh | sudo bash. 3. Sudo EXTERNAL_URL=" Go to the URL of GitLab (domain name or address) "yum -y Install gitlab-ee 3. Gitlab-ctl reconfigure configure 6. External _url for your own access to the URL (domain name or address) vi of GitLab /opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml 7. Change Windows hosts to start GitLab by adding their own URL (domain name or address) to the corresponding IP address: Gitlab-ctl start/stop/restart Gitlab-ctl start/stop/restart Gitlab-ctl start/stop/restart

IDEA software integration git (understand)

1. Create a library on GitHub 2. Open Idea software and select Setting --> Version Control --> git 3. Then select GitHub and add an account (you need to generate an authorized token on GitHub first). Use the token to add an account on GitHub and start using some features of Git. Any files you want to upload to GitHub are: Right click on this file --> git --> add/commit Want to push to remote repository: repostory --> clone/push/pull If there is a conflict, select merge