My current git commands commonly used in my work

Let me talk about it first: This article is suitable for students who have a little git foundation and have installed git on their computer. I just came to the workplace and are a little bit blinded. Because I crawled over this pit one by one, then I recommend Liao Xuefeng's git tutorial. I personally feel that Yes, I haven’t finished reading it myself, everyone encourages

I won't talk about the installation of git

 

1. If you go to a company, to use git, first install git, and then the second step is to know how to clone the remote project

The instruction is

git clone [路径]

2. You cloned the master branch, use

git branch -a

You can see all the remote and local branches

Development is not yet possible at this time,

3. Because your local is also a master branch, you need to switch to a functional branch

git checkout -b dev1 origin/dev1

-b means new

This instruction means to create a local dev1 branch and switch to the dev1 branch. This dev1 branch is created based on the remote dev1 branch

What you need to know is that this dev1 is a functional master branch, that is,

4. You still can't do things on this branch, then you need to do the following

git checkout -b dev1_barry dev1

This sentence is to create a new branch dev1_barry locally and switch, indicating that it is my own local branch, and then we can write code on this own functional branch

5. After writing the code, you need to push the local code to the remote. This process is:

git add .

git commit -m "你的注释"

git push origin dev1_barry

The first sentence is to put your code in the staging area, the second sentence is to synchronize your code to the local warehouse, and the third sentence is to push the code to the remote warehouse.

Then, things are not over yet, you just push your code to the remote, and your superior needs to merge your code into the functional master branch

How to do it, our company uses gitlab, in fact it is to submit a merge request, and then others will review your code before merging your code

Choose your own branch and where you want to merge this branch, then write a note, OK

 

Then, the problem came again, your colleague updated the code, and then you need to update your code, first look at the picture

Suppose we are now on the local my function branch dev1_barry, at this time our series of instructions is:

git add .

git commit -m "..."

git push origin dev1_barry

git checkout dev1

git pull

git checkout dev1_barry

git merge dev1

git add .

git commit -m "..."

git push origin dev1_barry

 

There are many more, update when you have time

// - 2019.7.26 => Because of the busy work, the update of csdn has been stopped for a long time, but I can't stop studying, so more of my information is currently in my Youdao notes (my I usually use the ones I know about the goods and collect them, and all the git problems I encountered will be put in them) -

http://note.youdao.com/noteshare?id=6680ccb12a30f9b435b2ce0f152cba33&sub=WEB92e67f0542697fd35d9710cc5a571bee

 

Guess you like

Origin blog.csdn.net/qq_38238041/article/details/88659930