vscode git/gitlens

本文介绍了如何在VSCode中使用GitLens插件首次创建和同步已有Git仓库。首先,通过`git init`、`git add.`、`git commit`、`git remote add origin`等命令将项目关联到远程仓库,并执行`git pull`和`git push`进行同步。对于已有仓库,只需`cd`到仓库目录,然后添加远程仓库并推送。遇到`fatal: refusing to merge unrelated histories`错误时,使用`git pull --allow-unrelated-histories`解决。如果出现无密码问题,可以配置`git config --global credential.helper store`。网络问题可能需要检查主机设置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

vscode git/gitlens


在这里插入图片描述

第一次创建

git init
git add . 将所有文件添加到本地git仓库
git commit -m "first commit"
git remote add origin https://github.com/XXX/xxxx.git 项目关联到远程仓库
git pull origin master
git push -u  origin master

同步

之后的同步
在这里插入图片描述

已有仓库

cd existing_git_repo
git remote add origin https://gitee.com/xxx/xxx.git
git push -u origin master

上传代码参考:https://blog.csdn.net/diaopa0703/article/details/101353127

其他

remote错误

git remote remove origin 删除设置重新配置

无密码
git config --global credential.helper store
fatal: refusing to merge unrelated histories

可能由于使用了官方的 .gitignore 自动合并失败,需要手动合并之后再进行 add、commit 即可

git pull origin master --allow-unrelated-histories

参考:https://blog.51cto.com/laok8/2454524

443无网络

host添加,参考:https://www.jianshu.com/p/0493dcc15d6f
比挂v要好

详细参考:https://blog.csdn.net/high32/article/details/111941127

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值