1. 打开Git Bash:
2.命令行-初始化本地仓库:
$ git init
3. 将目录下所有文件添加到本地仓库
$ git add .
4.将添加的文件提交到本地仓库:
$ git commit -m"first commit"
5. 与Github上新建的远程仓库建立链接:
$ git remote add origin https:****
6. 把文件push到远程仓库:
$ git push -u origin master
------------------------------------------------------
遇到的问题1:error: remote origin already exists.
问题定位: git remote -v
origin https://github.com/* (fetch)
origin https://github.com/* (push)
https://www.coder.work/article/1536836
问题2:$ git push -u origin master
error: src refspec master does not match any
error: failed to push some refs to 'https://github.com/ZZhaipei/cit693.git'
git status
On branch main
nothing to commit, working tree clean
问题3:
fatal: The current branch main has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin main
问题4:
$ git push origin master
error: src refspec master does not match any
error: failed to push some refs to 'https://github.com/ZZhaipei/cit693.git'
解决:
$ git push --set-upstream origin main
Enumerating objects: 116, done.
Counting objects: 100% (116/116), done.
Delta compression using up to 8 threads
Compressing objects: 100% (108/108), done.
Writing objects: 100% (116/116), 726.13 KiB | 6.31 MiB/s, done.
Total 116 (delta 19), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (19/19), done.
To https://github.com/*****
* [new branch] main -> main
Branch 'main' set up to track remote branch 'main' from 'origin'.