git 命令
标签(空格分隔): git 代码管理工具
- 查看git版本号 git –version
git version 2.15.0 //(安装成功的版本号)
- cd/文件夹位置
eg: cd Users/lipingran/Desktop/gittest
- 创建文件 (touch + 文件名)
- 配置用户名: git config –global user.name ‘名字’
- 配置email: git config –global user.name ‘41976695@qq.com’
- 添加文件 git add + (要添加的文件名)
- 添加全部文件 git add .
- 添加某类文件 git add *. + (文件格式)
git add *.html // 添加所有的html 类型的文件
- 删除文件:git rm –cached + (要删除的文件名)
- 查看状态: git status // 每次上传之前都需要查看一次
- 提交到仓库:git commit
成功后显示的提示如下:
/*此行填写备注信息*/
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# On branch master
# Changes to be committed:
# modified: index.html
#
~
~
~
~
~
~
~
"~/Desktop/gittest/.git/COMMIT_EDITMSG" 8L, 211C
操作: 按ESC 之后输入 :wq // 退出
- 提交到仓库2:git commit -m ‘要备注的信息’
- 忽略文件
1:touch .gitgnore //创建忽略文件
2:在 .gitignore 文件内添加要忽略的文件名或者文件夹
eg: 1.txt // 忽略1.txt 文件
/文件夹名 // 忽略文件夹 路径+文件夹名字
- 创建分支 git branch + (分支名字)
- 切换分支 git checkout (分支名字) // 在分支操作不会影响主线
- 切换主线 git checkout master