正常上传
先在github创建一个repository,勾选添加readme.md和LICENSE
在待上传的文件夹中右键Git Bash Here
依次输入
git init
git add .//有个空格
git commit -m "first commit"
git remote add origin git@github.com:Indifference061/Leap_jugde.git//后加SSH的地址
git push -u origin master/main
出现错误
- 若出现error:failed to push some refs to
则需要先pull原有的文件到本地
git pull origin main --allow-unrelated-histories
ps:若出现fatal: couldn’t find remote ref main导致无法pull可能是因为远程仓库出现错误,要删除现有仓库并重连
git remote rm origin
git remote add origin SSH
若出现fatal:refusing to merge unrelated histories
git pull origin main --allow-unrelated-histories
最后只需要重新push
git push -u origin master/main
- 若出现Everything up-to-date,则需要重新创建新的分支
git branch newbranch
git branch//查看是否创建成功
git checkout newbranch//切换到新分支
按照上面之前的提交重新提交到newbranch
转换为main并合并删除newbranch
git checkout main
git merge newbranch
git push origin --delete newBranch
最后上传到main分支
git push -u origin main
版本更新
当需要增加一个文件
git add .//有个空格(或者将.替换成文件名)
git commit -m "second commit"
git remote add origin git@github.com:Indifference061/Leap_jugde.git//后加SSH的地址
git push -u origin main/git push -u
需要删除某个文件
git rm 文件名
git commit -m "remove file"
git push -u