You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
msb_23480
b9236106ef
|
1 year ago | |
---|---|---|
README.md | 1 year ago |
README.md
功能: 练习从命令行创建一个新的仓库
touch touch README.md # 创建说明文件
git init # 初始化仓库 注意在创建的仓库目录下执行
git checkout -b main
git add README.md # 将文件加入到本地仓库发送列表
git commit -m "first commit" # 提交这个文件到本地仓库
git remote add origin https://git.mashibing.com/msb_23480/first_msbwarehouse.git #配置远程仓库地址
git push -u origin main # 推送文件到远程仓库分支
问题
# 使用git push -u origin main 时出现错误
error: src refspec main does not match any
error: failed to push some refs to 'https://git.mashibing.com/msb_23480/first_msbwarehouse.git'
# 分析:GitHub 从今年 10 月 1 日起,在该平台上创建的所有新的源代码仓库将默认被命名为 “main”,而不是原先的"master"。
# 解决思路:把本地的 master 仓库名称修改为远端的 main
# 重命名命令: git branch -m oldBranchName newBranchName
# 解决:
git branch -m master main # 把本地的 master 仓库名称修改为远端的 main
# 然后再次提交
git push -u origin main
在git平台对文件进行修改
新增一行内容 # 新增的内容
# 如果远程文件做了修改 ,使用git pull 同步
git pull # 远程同步最新内容
克隆到本地
git clone https://git.mashibing.com/msb_23480/first_msbwarehouse.git