Git 快速教程
来源:互联网 发布:淘宝上怎么关闭订单 编辑:程序博客网 时间:2024/05/20 18:18
流程: 取代码 → 每次工作前更新代码到最新版本 → 修改代码 → 提交代码到服务器
1. 取代码及修改全局设置
a. 设置用户名与邮箱
git config --global user.name "My Name"git config --global user.email "my@email.com"
b. 从已有的git库中提取代码
git clone git@server:app .git myrepo
2. 每次更改代码的操作
a. 更新本地代码到最新版本(需要merge才能合到本地代码中)
git fetch
b. 合并更新后的代码到本地
git merge
c. 更新代码方式的另一种方法(git pull是git fetch和git merge命令的一个组合)
git pull
d. 修改代码后,查看已修改的内容
git diff --cached
e. 将新增加文件加入到git中
git add file1 file2 file3
f. 从Git中删除文件
git rm file1git rm -r dir1
g. 提交修改
git commit -m 'this is memo'
如果想省掉提交之前的 git add 命令,可以直接用
git commit -a -m 'this is memo'
commit和commit -a的区别, commit -a相当于:
- 第一步:自动地add所有改动的代码,使得所有的开发代码都列于index file中
- 第二步:自动地删除那些在index file中但不在工作树中的文件
- 第三步:执行commit命令来提交
h. 提交所有修改到远程服务器,这样,其它团队成员才能更新到这些修改
git push
3. 附注
遇到过的一些错误:
Git – fatal: Unable to create ‘/path/my_project/.git/index.lock’: File exists.
fatal: Unable to create ‘/path/my_proj/.git/index.lock’: File exists.
If no other git process is currently running, this probably means a
git process crashed in this repository earlier. Make sure no other git
process is running and remove the file manually to continue.
可以试着删除 index.lock
rm -f ./.git/index.lock
- Git教程 快速上手
- <<git使用快速教程>>
- Git 快速教程
- <<git使用快速教程>>
- git快速上手教程
- Git教程 快速入门
- Git精简教程,快速上手
- Git精简教程,快速上手
- Git 快速上手精华教程
- 学习日记-Git快速教程
- Git常用命令集教程指南-快速入门
- GitHub快速入门简单教程以及常用Git 命令
- Git安装及配置5分钟快速教程
- Git超级傻瓜教程[快速创建Git远程项目并上传本地代码]
- Git教程
- git 教程
- git 教程
- git 教程
- V4L2应用程序框架
- makefile详解(07) 清空目标文件的规则
- ubuntu中终端TAB键不补全命令解决办法
- 怀旧:制作一款复古风格的游戏
- CCW 下填Modbus Mapping简单方法
- Git 快速教程
- 程序算法与人生选择
- C语言:获取某个mysql数据库中所有的表及其表中所有的字段名
- FusionCharts实例下载(ASP,ASP.NET,PHP,JSP......)
- tostring 的格式化输出
- 计算机开放端口问题
- wenku(一)
- 关于内存管理,写一个简单易懂的教程
- 几个很特别的音乐搜索网站