I once asked all the programmers in the hall because of a Git problem, that is, I pushed the code, but the warehouse could not see it, so no one knew about it. Later, when I looked into it more closely, I realized that the branch was only created locally, but not pushed remotely. Later I thought about it and summarized the commands I had used

Get the files locally

When you start work, you have to get the documents locally

Git remote add Origin address and git pull origin master

Git Clone address

Of course, if you are using a company computer, you may be able to use the previous person’s code

Create a branch

Git branch youyuxi git branch youyuxi git branch youyuxi git branch

Push the code

Git status Add a note git commit -m ‘I am a note’ and push git push

Then click OK and it will ask you to enter your password, which you can then enter

In this process, I found that it was necessary to input the account and password again when submitting the code. I was a little upset, so I looked up the relevant technical data

You can type git config –global Credential. helper store before entering your account and password

So the personal information is automatically saved

Merging branches

In order to be consistent with the master branch, and in case the files of two people are too far apart, branches should be closed several times a week

1. Switch to the main branch first

git checkout master

2. Use Git pull to pull down the leading master branch code

git pull

3. Switch to your branch

Git Checkout XXX

4. Merge the main branch code into your own branch

git merge master

Git push ok, now your branch code is the same as the main branch code

git push

The fallback

Git reset –hard HEAD^

Many people now use a variety of tools to upload code, such as vscode’s own git plug-in is easier to use than using git commands directly. When I make a change, I use vscode source control to see what I’ve changed before I submit it

References:

www.cnblogs.com/robinbingo/…