git基本操作
2016-10-09 19:36
155 查看
新建文件夹
git add -A 将所有文件加入到索引库中
git add README 仅增加README文件
此时文件处在“staged”状态,对文件进行了快照,保存在暂存区域,尚未交付到git仓库中。
http://www.codeweblog.com/git%E4%B8%AD%E6%96%87%E4%BB%B6%E7%9A%84%E4%B8%89%E7%A7%8D%E7%8A%B6%E6%80%81/
[root@localhost home]# mkdir gittest [root@localhost home]# cd gittest [root@localhost gittest]#git初始化
[root@localhost gittest]# git init Initialized empty Git repository in /home/gittest/.git/修改用户名和邮件
[root@localhost gittest]# git config user.name "Leon Nan" [root@localhost gittest]# git config user.email leon0820@126.com创建文件
[root@localhost gittest]# echo "init file" >> README [root@localhost gittest]# cat README init file此时文件处在“Untracked”状态,即不受git管理,未被追踪的状态。可通过git status查看
[root@localhost gittest]# git status # On branch master # # Initial commit # # Untracked files: # (use "git add <file>..." to include in what will be committed) # # README nothing added to commit but untracked files present (use "git add" to track)添加文件,使文件接受git的管理
git add -A 将所有文件加入到索引库中
git add README 仅增加README文件
[root@localhost gittest]# git add README
此时文件处在“staged”状态,对文件进行了快照,保存在暂存区域,尚未交付到git仓库中。
[root@localhost gittest]# git status # On branch master # # Initial commit # # Changes to be committed: # (use "git rm --cached <file>..." to unstage) # # new file: README #交付文件,将保存在暂存区域的快照永远保存到git仓库中。
[root@localhost gittest]# git commit -m "init file" [master (root-commit) 7c4a592] init file 1 files changed, 1 insertions(+), 0 deletions(-) create mode 100644 README查看git状态及log
[root@localhost gittest]# git status # On branch master nothing to commit (working directory clean) [root@localhost gittest]# git log commit 7c4a592e4221c349dfad6dbda3f4056d47360191 Author: Leon Nan <leon0820@126.com> Date: Mon Oct 10 03:07:26 2016 +0800 init file修改文件
[root@localhost gittest]# echo "modify file" >> README [root@localhost gittest]# [root@localhost gittest]# [root@localhost gittest]# cat README init file modify file此时文件处在modified状态
[root@localhost gittest]# git status # On branch master # Changed but not updated: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: README # no changes added to commit (use "git add" and/or "git commit -a")添加文件,再次commit
[root@localhost gittest]# git add -A [root@localhost gittest]# git commit -m "modify file" [master 3bb3528] modify file 1 files changed, 1 insertions(+), 0 deletions(-)查看文件log
[root@localhost gittest]# git log commit 3bb352807d3dddef1efd88a60805b6e09fb16ae1 Author: Leon Nan <leon0820@126.com> Date: Mon Oct 10 03:33:35 2016 +0800 modify file commit 7c4a592e4221c349dfad6dbda3f4056d47360191 Author: Leon Nan <leon0820@126.com> Date: Mon Oct 10 03:07:26 2016 +0800 init file [root@localhost gittest]# git status # On branch master nothing to commit (working directory clean)参考文件:
http://www.codeweblog.com/git%E4%B8%AD%E6%96%87%E4%BB%B6%E7%9A%84%E4%B8%89%E7%A7%8D%E7%8A%B6%E6%80%81/
相关文章推荐
- git学习三 git基本操作
- Git基本概念及操作(1)
- Git基本命令行操作
- git学习 #2:git基本操作
- git学习 #2:git基本操作
- 一步一步学习Git(2)——Git基本操作
- my project 中git使用过程(基本操作流程)
- Git基本操作
- git简介、安装、基本操作——Git折腾小记
- git学习 #2:git基本操作
- Git基本概念及操作(2)
- git一些基本操作备忘
- Git操作流程,基本命令演示
- Git 基本操作
- git config命令使用第一篇——介绍,基本操作,增删改查
- pro git 阅读笔记1 基本操作
- git 基本操作与规范流程
- windows下GIT使用记录--01基本操作
- git基本操作
- my project 中git使用过程(基本操作流程)