[Tool usage] git basic operation 1

16051211:

1. Pull the git code

Note:
1. Pull the code for the first time and git cloneexecute it directly later git pull origin <分支名>, or directly git pull(provided that the local branch is associated with the remote branch, and executed if there is no association git branch --set-upstream-to=origin/分支名)

1. Pull command for the first time

$ git clone url

1.1 The command line must execute the following commands every time the code is pulled:

git checkout 分支名

2. Use graphical pull code

insert image description here

3. Idea development tools pull code

2. View the current status

1. Check if the file has been modified again since your last submission

$ git status

3. Create a branch

3.1. Create a branch

$ git branch feature-online

3.2. Create a branch and switch to the branch

$ git checkout -b feature-online

3.3. Submit the branch to the remote warehouse and the remote is not automatically created

$ git push origin feature-online

4. View branch

4.1. View the current branch of the local branch

git branch

4.2. View remote warehouse branch

$ git branch -r

5. Merge code

5.1 pull merge

1. First switch to the branch

git checkout feature-online

2. Use git pull to pull the branch code down

git pull

3. Switch to the master branch

git checkout master

4. Merge the code of the branch to the main branch

git merge feature-online

5. Push up to complete

git push

Now the code from your own branch is merged into the master branch

5.2 fetch merge

1. First, the latest commit of the target branch of the remote warehouse is recorded in the ./git/FETCH_HEAD file

git fetch origin feature-onlin

2. The name of the branch to be merged is switched to the branch to be merged

git checkout master

3. Merge the latest commit record of the target branch into the current branch

git merge FETCH_HEAD

6. Submit code for the first time

1. Go to the root directory and execute git add. Add all files to git version control

git add .

1.1 Enter the root directory and execute git add to add the specified file to git version control

git add <file>

2. Execute git commit to submit the information submitted to the local -m

git commit -m ‘提交信息’

3. Push up to complete

git push

other

1.git official website operation

https://git-scm.com/book/zh/v2/%E8%B5%B7%E6%AD%A5-%E5%AE%89%E8%A3%85-Git

2. Rookie Tutorial

https://www.runoob.com/git/git-tutorial.html

Guess you like

Origin blog.csdn.net/Daisy74RJ/article/details/132056289