This is the 20th day of my participation in the Genwen Challenge

1. Common commands

When you commit code with Git, the most common ones are:

Git branch Displays all local branches

Git status Displays the current git status

Git checkout dev switches to the local dev branch

Git pull pulls remote code locally

git add .

Git commit -m

Git push pushes code to remote

Make it a habit to leave the latest code behind.

How to resolve version conflicts

To merge your code branch into the Daily branch, switch to Daily, open the branch selection list, click on the triangle to the right of the local branch you want to merge into, and select Merge into Current.

After merge is done, if there is no conflict, push can be done directly.

If a conflict occurs during code submission, the visual interface of IDEA usually has three parts:

On the left is the last version of the code, in the middle is the current version, and on the right is the new code you’re submitting

Just read the code carefully, click the front arrow ➡️ on what you want to keep, and make sure to check that the intermediate version is what you want.

If there are conflicts, resolve them first, then add – commit – push.

Third, version view

Idea also has many useful quick query methods,

Compare with Branch…

Version Control–Log is the historical submission record of the current file, and can also be withdrawn to a certain Version of the code.

If you’re using Git from 0, start here.

How do I manage my code in Git when I create a local project?

– Create a local Gradle project with three names: project package name, project name, and file name

– Log in to Gitlab and [Create project] on gitLab. After successful creation, you can see the following command line. Remember this picture. It’s useful.

The first is the global Settings, open the project source code folder to execute.

The second is to clone the project above git to the local project, create a new file named TestName project, the subsequent can be code management.

The third is the local existing project project, which associates git projects with local project projects.

Project does not exist or could not be found

You might need to install.SSH.

Configure the. SSH file

Where can I find the.ssh file for Mac

Finder–> Go to –> Go to folder –> enter ~/.ssh

That is, shift+command+G–> enter ~/.ssh

  • Operation:

Open the terminal and access the local project directory

# git config –global user.name “yourname”

# git config –global user.email “[email protected]

Delete “known_hosts” from “.ssh “.

Continue operating terminal

# ssh-keygen -t rsa -C “[email protected]

appear

Generating public/private rsa key pair.

Enter file in which to save the key (/Users/your_user_directory/.ssh/id_rsa):

– press enter

– Keep pressing y

– Enter the password XXXXXXXX

Then the system automatically generates two files, id_rsa and id_rsa.pub, in the. SSH folder. Open id_rsa.pub with notepad

Copy all the content

Open the Gitlab address, log in to your account, and go to Settings.

Go to.ssh Settings, paste the one you just copied in key, and hit Add SSH Key.

The above Settings are complete.

Official development code

Open IDEA and connect the warehouse.

Create a new branch instead of working directly on the master branch.

  • Go to the local project project, create a new local branch dev, and switch to that branch
  • Enter the git command on the terminal

# git pull (will fail because there is no remote dev branch yet)

# git push –set-upstream origin dev

Then enter Git pull Origin master

git push

Start developing.