GitHub uploads projects and modifications (only for self-recording and learning)

Just for my own notes, if someone points out the mistake, I would be very grateful

If login is involved in the middle, only use the token to log in with the specific token to get the connection: https://github.com/settings/tokens/new

1. Upload

First create a project on the github website, don't choose an initial readme when building it
#There is a readme in your own project, if not, it is said that an error may be reported
in the project folder git bash hear

git init
git  add .
git commit -m "first commit"
git branch -M main  #-M重命名你的分支为main
git remote add origin 你的项目地址
git push -u origin main

(I think it can be understood in this way, main is equivalent to your local (but in fact it seems to be a branch), origin is equivalent to your remote is the one on github, and then push origin main to the remote one to upload your local (thinking of))

2. About the code update of the warehouse

Reference: https://www.cnblogs.com/kumata/p/9061166.html
If there is no connection between your warehouse and the code,
create a folder
and open git bash in it, and then first upload the warehouse that needs to be updated from github cloned down
into that repository

git add. #把它原来的全覆盖
git commit -m "描述信息"
git push #注意文件不要太太大,要不然会传不上去报错

Successful result:insert image description here

The above method is that your project and the github warehouse have not established a connection.
After this method is done, you can directly modify it in the warehouse that git cloned here (you can move this cloned warehouse to any location on your computer disk) because at this time your local project and your remote The warehouse has already established a connection, so you can directly modify it here in the future.
Every time the modification is completed, just

git add 你更新过后的文件
git commit -m  "这次的提交信息"
git push

Supplement: tag (make your code into version form)

git tag tag名字#添加一个tag
git log --pretty=oneline --abbrev-commit #查看历史commit
git tag v1.0 commitid #给某次的commit打上一个tag#这个commitid 来源于你上一条查看的历史commit的一个id号
git push origin v1.0
git tag -d tag名字 #删除tag

Guess you like

Origin blog.csdn.net/qq_43545501/article/details/124354159