Create a project

Globally install vUE scaffolding, vUE project name support hump such as: firstProject.

Click on the Vue official document for details

Vue: NPM install –global vue@cli

Vue: vue create <project name>

Install react globally. I’m not familiar with React. There may be other install packages.

The React project does not support humps. For example, “firstProject” will cause project creation to fail.

react: npm install -g create-react-app

react: create-react-app <project name>

See the React official tutorial for more details

However react’s official tutorial is a bit difficult to understand, pure new beginners can see the novice tutorial

2. Create a code repository

Code warehouse can choose Github, code cloud, or other code platform according to their own hobbies, there is no great difference in daily work, the following code cloud for example, not github because there are some cards.

1. Login platform: Picture: omitted
2. Create the warehouse: Code cloud finds the warehouse in the lower left corner and clicks “+” to create a new warehouse, and then completes the creation of the warehouse according to the guidance of the text on the web page.

3. Generate an SSH public key

Open the terminal locally. It is recommended to download the Git terminal and enter the following command:

Generate a public key:

Ssh-keygen -t rsa -c “Key name”

View the public key:

cat ~/.ssh/id_rsa.pub

After entering the above command, you can see a string of common public keys as shown in the following figure

4. Bind the code platform

The purpose of this step is to bridge the local to the repository, telling the repository that it is not an outsider.

Go to the code base and go to your profile picture -> Setting -> SSH and GPG Keys.

The interface is shown below, and the title depends on your mood. I usually fill in “company” or “laptop” to indicate my company or my laptop.

3. Local code is pushed to the code base for the first time

1. Initialize the project

Go to the new project folder and use the git init command to initialize the project

cd <project name>

git init

This step is equivalent to creating a code base locally. After the preceding commands are executed, see figure.

The next step is to add the repository address, also known as the linked repository, to your project

git remote add origin [email protected]:ruoyuonline/c**r.git

The origin command is a local nickname for the repository, which will be used later. The default value is Origin, which can be changed.

git add .

Git commit -m ‘initialize project’

git push -u origin master

When you first push your project to the repository, run the command above, with the -u parameter specifying the default branch to be pushed to, and then use Git push to push the project to the master branch by default. You can also use git push origin <branch name> to push to a specified branch.

Iv. Synchronous branch and conflict resolution

1, description,

Synchronous branch is mainly used for multiplayer cooperative development, single development of the case, can also refer to use.

First, open the cloud platform and enter the project warehouse. You can see the default master branch in the upper left corner, and then you can manage the branch through the drop-down menu.

In multi-party development, it is recommended to create temporary dev branches for development, and allocate the branches under the dev branch to each developer

2. Synchronize branches locally

After many experiments, I have not found a local pull branch method

git checkout -b user1 origin/user1

This command is to pull origin’s user1 branch to the local user1 branch, which can be named another.

Multiple branches, more than a few times, switching the corresponding name can be.

Accidentally created the wrong local branch execute the following command to delete

git branch -d <branch name>

3. Code merge

As the team leader, there are two ways to merge code. One is to create temporary branches locally, pull the branches of the various developers in the remote repository and merge them.

Git checkout -b temp origin/user1 git checkout -b temp origin/user1

git pull origin user1

git checkout dev

git merge temp

The first merge requires executing the first command, then pulling the remote branch, switching to the dev development branch, and merging the code.

git status

The above command can view the local merge changes, green represents the new non-conflict, red code deleted or conflict files.

** Special note: If there is a conflict, the command line will prompt you to resolve the conflict.

Below the master will switch to master | MERGEING * *

If the word “both MODIfed” appears, it means that the file conflicts with the code of the existing file and cannot be directly merged, which needs to be manually merged.

This is how you can use vsCode software to open conflicting files and decide how to merge your code

4. Upload after resolving the conflict

After the code conflicts have been resolved, you can execute the following commands

git status

Check whether there are still conflicting files, modify modify, delete delete type can be ignored depending on the situation.

git add .

Git commit -m ‘merge conflict’

git push origin dev

5, the end

The above steps can basically meet the daily development needs. After completing a phase of development, you can create a branch in the code base with the version number, and push the current code into the corresponding version branch to complete the last step of version management.