git基本问题

创建远程仓库提交本地代码到远程仓库:

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// 初始化git仓库
git init
 
// 添加当前文件到git仓库
git add .
 
// 提交代码到暂存区
git commit -m "Initial commit"
 
// 关联远程仓库
git remote add origin [仓库的URL地址]
 
// push代码到远程仓库的分支(master)
git push -u origin master
 
// push的时候如果出现以下报错的话
// fatal: unable to access 'https://github.com/<GITHUB_USERNAME>/<GITHUB_REPONAME>.git/':
// OpenSSL SSL_con nect: Connection was reset in connection to github.com:443
// 可以通过在github -> Developer settings -> Personal access tokens -> 创建一个对应git仓库的token并设置repo权限,设置远程仓库的token,再提交即可
 
git remote set-url origin https://<TOKEN>@github.com/<GITHUB_USERNAME>/<GITHUB_REPONAME>.git
 
git push -u origin master  
 
 
 
 
// 拉代码遇见此种情况一样的解决方式
git clone http://username:<token>@gitlab-url/git_repo.git

  

posted @   cs7  阅读(8)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
点击右上角即可分享
微信分享提示