Song sharing: city of stars Ryan Gosling
City of stars,
are you shining just for me?
City of stars,
there’s so much that I can’t see.
is this the start of something wonderful and new,
or one more dream that I cannot make true?
Forgetting in the Jianghu, they all realized their dreams and were well!
1、 Basic understanding
In the development process of one or more people, it is necessary toVersion of the codeManagement, so as to facilitate the control of development progress.
Git is an open source distributed version control system for agile and efficient handling of any small or large project.
Git is an open source version control software developed by Linus Torvalds to help manage Linux kernel development.
Download link: https://git-scm.com/download/win
After installation, right-click to see git Bash and git GUI
At this time, do not forget to do some initialization configuration!!!Otherwise, when you submit the code and your supervisor doesn’t know who submitted it, there will be only embarrassment and others will know that you have just entered the industry.
1： Right click: git Bash 2: Enter your name and email address in double quotation marks git config --global user.name "Your name" git config --global user.email "Your email" 3: Config is followed by L of list, not the number 1 or the letter I View information: git config - L
3、 Git architecture
Version Library:In the project, after git init, there will be a. Git directory. This directory does not belong to the workspace, but the GIT version library, which manages all the contents of GIT.
Staging area:A temporary storage area in the version library that holds submitted files.
Branch:The version library includes several branches. Files submitted from the staging area will form a version (submission point) in the branch.
4、 Warehouse (version Library)
Warehouse:Is a directory in which files are managed by GIT
Create a new warehouse:In a directory, run git init
1. View warehouse status: git status
2. Submit all modified files to the staging area: git add
be careful:The word add is followed by a space and then a dot. This method is to submit all modified files to the temporary storage area. If you only want to submit some files, you can directly write the modified file name prompted in status after the add space.
3. Submit the files in the staging area to the branch to form a version / submission point: Git commit - M "information submitted this time"
4. Submit new branch: git push origin branch name
5、 Remote warehouse
The warehouse just mentioned is actuallyLocal warehouse, in multiplayer development, everyone will have their own local repository. At the same time, more importantly, in order for multiple people to share code, there should be oneRemote warehouse.
Selection of remote warehouse:
- Code cloud
- Remote warehouse built within the company
Operation of remote warehouse:
1. Register GitHub account
2. Create an empty warehouse
3. The directories that need to be submitted to the remote warehouse are as followsOperation:
1. Initialization Directory: git init 2. View the current status: git status 3. Submit to staging area: git add 4. Submit to a version: git commit - M 'first commit' 5. Create an address remotely: git remote add origin GitHub warehouse address 6. Submit the current version to the master branch of the remote address: git push - U origin master
Sharing and cloning of remote warehouses:
At this time, we have our own remote warehouse, and the files we just submitted are already on the master branch in the warehouse.
At this time, if other personnel need to download this project, you need to clone the GIT clone warehouse address. In the following two ways, you do not need to enter a user name and password when cloning a project in the future
1. Clone using HTTPS:
Use this link to save the method in the user name and password. You don’t need to enter the account and password every time you clone the project
2. Clone Using SSH:
1. No pub indicates that you have not set the local computer public key 2. Directly three OK, do not enter yes 3. With the pub file, copy the contents and add the public key to your company's remote settings 4. View remote address: git remote - V
6、 Branch (timeline)
There can be multiple branches (Master, dev, test) in a remote warehouse, and the version we submitted before is stored on one branch. With the increase of submission times, a timeline will be formed on the branch, and each git commit operation will form a version on the branch.
1. View branch: git branch 2. Create a new branch and copy the current branch: git branch branch branch name 3. Switch branch: git checkout branch name 4. Submit the new branch: git push origin head - U
Each branch has a pointer. By default, the pointer will point to the latest version on the branch.
1. Branch submission log query: git log
2. Branch merge: merge one branch onto another Git merge branch a ： Merge branch a onto the current branch
- Rapid merger (those with strong ability can have an in-depth understanding)
- Three party merger (those with strong ability can have an in-depth understanding)
8、 Additional operation commands:
1. View the project folder (s is preceded by L of the word long): LS - al 2. Create a branch and switch to it: git checkout - B branch name 3. View remote address: git remote - V
9、 Multi person development scenario code conflict:
1. If someone else git pushes the code first, then git push will not succeed. Git bash will prompt you that your code version lags behind the remote warehouse. At this time, you need to update git pull to the latest version before git push can succeed.
2. Of course, more conflicts can be solved step by step according to the GIT prompt, as shown below.