git 命令总结(持续更新)
2021-05-10 本文已影响0人
90后的晨仔
-
一、初始化仓库给仓库添加git
git init
-
二、
git add
添加单个与多个文件的方法 - 1.添加单个文件
git add file
- 2.添加多个文件方法1
git add file1 file2 file3
- 3.添加多个文件方法2
git add file1
git add file2
git add file2
- 4.添加多个文件方法3
git add . 或者 git add --all
-
三、添加文件夹
git add testFolder (文件夹名称)
-
四、文件从暂存区提交到版本库
git commit -m "add new file"
-
五、本地仓库与远程仓库建立链接
git remote add origin https://github.com/624990742/JCMaNongChenZaiTest.git
-
六、本地仓库与远程仓库同步一下内容
git pull origin master
-
七、本地文件推送到远程服务器
添加了
-u
参数,以后即可直接用git push 代替git push origin master。
git push -u origin master
-
八、其他常用命令:
git rm 'JCMaNongChenZaiTest/Classes/ReplaceMe.m'
删除指定文件
git restore 'JCMaNongChenZaiTest/Classes/ReplaceMe.m'
恢复指定文件
git checkout master
切换分支到master
git merge hotfix
合并分支
git merge master --allow-unrelated-histor
若两个库没关联在后边加--allow-unrelated-histor