git使用错误记录

将暂存文件的提交到本地仓库

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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值