upload files on github

1. new Create a new warehouse

Complete/tick the three sections below
insert image description here

2. Right-click the local file to be uploaded, and select "Git Bash Here" to enter.

insert image description here
Enter the git interface:
insert image description here

Third, enter the following commands in turn

1. Generate readme file.

echo "# 在这里填入readme里面的内容" >> README.md

insert image description here

2. Create a local warehouse and initialize the version library.

git init

insert image description here

3. Add the file to the local repository.

git add . 

insert image description here

4. Submit to the local cache area, and the quotation marks are comments, which are used to explain what was submitted.

git commit -m "填写备注"

insert image description here

5. Submit the code of the local warehouse to the remote github warehouse.

git remove add origin 此处填写自己新建的github仓库地址

GitHub warehouse address:
insert image description here

Code example:
insert image description here

6. Push the code of the remote warehouse to the master branch.

git push -u origin master 

insert image description here
Enter your own warehouse on github, refresh, and you can see the successfully uploaded files:
insert image description here

Fourth, modify the master to default

insert image description here
If main is the default, but we want to set the master as the default, we can do the following:
insert image description here
the default will become the master branch:
insert image description here

other

1. Note: When using Git for the first time, a window will pop up asking you to log in. Don't click "Sign in with your browser", it's easy to make mistakes. If an error occurs after clicking, the following codes can be executed in sequence:

git remote remove origin

Then retype:

git remote add origin https://github.com/CZH-qm/BMI.git
git push -u origin master

Then click "Sign in with a code" this time, and enter your git password in the next step.
2. Check your git username:

git config user.name

Check your git password:

git config user.password

Set your own git password:

git config --global user.password "xxxxxxx"

If you just set your own git password, and then execute the follow-up command, an error will be reported: "fatal: unable to access 'https://github.com/CZH-qm/BMI.git/': Failed to connect to github.com port 443 after 21040 ms: Couldn't connect to server"
as shown in the figure:
insert image description here
then enter the following codes in sequence:

git config --global --unset http.proxy
git config --global --unset https.proxy

Then execute "git push -u origin master" and it will be OK.
insert image description here

Guess you like

Origin blog.csdn.net/weixin_44934373/article/details/128958039