git简单用法

首次创建 / 推送

1
2
3
4
5
6
7
8
9
10
11
12
# 首次创建新的存储库
git init
git add README.md
git commit -m "first commit"
git branch -M main # 与远程仓库中的分支对应
git remote add origin https://github.com/it-kay/234324.git
git push -u origin main

# 从命令行中推送到现有的存储库
git remote add origin https://github.com/it-kay/234324.git
git branch -M main # 与远程仓库中的分支对应
git push -u origin main

删除远程库中指定文件

1
2
3
git rm -r --cached a/2.txt //删除a目录下的2.txt文件   删除a目录git rm -r --cached a
git commit -m "删除a目录下的2.txt文件"
git push

克隆指定分支

1
2
git clone -b <分支名> <远程仓库URL>
git clone -b feature-branch https://github.com/user/repo.git // 示例