GitHub upload local folder project

After finally running out of Unet, I want to start using GitHub to manage files and make some notes to facilitate follow-up operations.

Pre-configuration

  • Create an account and skip it.
  • Configure your username and email in the terminal
$ git config --global user.name "struggler176393"
$ git config --global user.email "[email protected]"
  • establish ssh connection
$ ssh-keygen -t rsa -C "[email protected]"

Copy the SSH KEY (in home/.ssh/id_rsa.pub) generated locally, select Settings-SSH and CPG Key-Add SSH KEY on Github, and fill in the copied key in the box to complete the encryption.

Start upload

  • Click New in Repositories to create a new warehouse.
  • Under the local folder:
git init #建立git仓库
git add . #添加所有文件
git commit -m "注释的话" #提交到仓库
  • Associate the new warehouse with the local warehouse
  • If git remote add origin https://github.com/struggler176393/Unet_Pytorch.git
    appears fatal: 远程 origin 已经存在, delete the previous origin command and remote add again.
git remote rm origin
git remote add origin https://github.com/struggler176393/Unet_Pytorch.git
  • Create a new branch and upload
git branch -M main
git push -u origin main #-u可以不加

There may be another problem here. GitHub does not support a single file with a capacity greater than 100M, so some large files need to be ignored when uploading, otherwise an error will be reported. Create a new .gitignore file in the local folder, and add the ignored files or folders in it. The ignored format can be viewed at http://t.zoukankan.com/fancyblogs-p-12299731.html . Simply put, To ignore the b folder under the a folder under the current folder, add it in the .gitignore file a/b/, ignore the c file under the b folder under the a folder under the current folder, and add it in the .gitignore file a/b/c.
Then:

git rm -r --cached . #删除缓存
git add .
git commit -m '123'
git push -u origin main

When pushing, you need to enter the user name and password. The user name is the user name of the github account, and the password is the unique token of github. To apply for the token, see the following link: https://blog.csdn.net/HUASHUDEYANJING/article/details/126521798 .

Guess you like

Origin blog.csdn.net/astruggler/article/details/128264244