将暂存文件的提交到本地仓库
G:\C\Test1>git commit -m "first commit"
On branch master
Initial commit
Untracked files:
.vscode/
DataStructure/
file/
test.code-workspace
test1.c
test1.exe
nothing added to commit but untracked files present
这些都是没有暂存的,所以无法提交
将本地的文件上传到远端
G:\C\Test1>git push -u origin master
error: src refspec master does not match any.
error: failed to push some refs to 'https://github.com/WhlckCat/LearnC'
这是因为本地的仓库啥都没有,所以无法push
G:\C\Test1>git push -u origin master
To https://github.com/WhlckCat/LearnC
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/WhlckCat/LearnC'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
这是因为远端和本地的不匹配,需要先pull一下
git pull origin master
G:\C\Test1>git pull origin master
From https://github.com/WhlckCat/LearnC
* branch master -> FETCH_HEAD
fatal: refusing to merge unrelated histories
这是因为远端认为本地的仓库和自己无关,所以需要强行关联一下
git pull origin master --allow-unrelated-histories