Git 暂存修改文件 取消暂存
2018-01-18 10:31
531 查看
序:Git 已经用了不少年了,起步用的SourceTree ,所以对命令不是很熟悉,最近换了台电脑,索性不按sourceTree了,总结下命令行。
Git 最经常使用的操作就是:
工作空间----已修改文件----暂存----提交到本地git---push到远程git
这是一条我们没有特殊需求,没有出现错误和冲突的流程。
1.查看工作空间已修改的文件
git status
example:
zhangyudeiMac:server-psi zhangyu$ git statusOn branch masterYour branch is up-to-date with 'origin/master'.
Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory)
modified: web/Application/Common/Conf/config.php modified: web/Application/Mobile/Controller/PurchaseDetailController.class.php modified: web/Application/Mobile/View/Purchase/purchaseList.html modified: web/Application/Mobile/View/PurchaseDetail/purchaseDetail.html modified: web/Public/Scripts/Mobile/PurchaseDetail/PurchaseDetail.js
no changes added to commit (use "git add" and/or "git commit -a")
2.上个命令我们就可以看出所有修改过的文件,让后我们应该暂存这些文件。
* 单文件暂存
git add "Path(文件路径)" example:
zhangyudeiMac:server-psi zhangyu$ git add web/Application/Mobile/Controller/PurchaseDetailController.class.php
* 暂存全部已修改文件
git add -u
example:
zhangyudeiMac:server-psi zhangyu$ git add -u zhangyudeiMac:server-psi zhangyu$ git status On branch master Your branch is up-to-date with 'origin/master'.
Changes to be committed: (use "git reset HEAD <file>..." to unstage)
modified: web/Application/Common/Conf/config.php modified: web/Application/Mobile/Controller/PurchaseDetailController.class.php modified: web/Application/Mobile/View/Purchase/purchaseList.html modified: web/Application/Mobile/View/PurchaseDetail/purchaseDetail.html modified: web/Public/Scripts/Mobile/PurchaseDetail/PurchaseDetail.js
3.暂存的文件都是要为提交做准备的文件,如果我们有些文件已经暂存了,我们想还原到非暂存怎么办。
git reset "Path(文件路径)"
example: zhangyudeiMac:server-psi zhangyu$ git reset web/Application/Common/Conf/config.php Unstaged changes after reset: M web/Application/Common/Conf/config.php zhangyudeiMac:server-psi zhangyu$ git status On branch master Your branch is up-to-date with 'origin/master'.
Changes to be committed: (use "git reset HEAD <file>..." to unstage)
modified: web/Application/Mobile/Controller/PurchaseDetailController.class.php modified: web/Application/Mobile/View/Purchase/purchaseList.html modified: web/Application/Mobile/View/PurchaseDetail/purchaseDetail.html modified: web/Public/Scripts/Mobile/PurchaseDetail/PurchaseDetail.js
Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory)
modified: web/Application/Common/Conf/config.php
4.最后一步是提交到本地git和push到远程git,估计都会还是贴上吧。
zhangyudeiMac:server-psi zhangyu$ git commit -m "bangdingwuliuadd"
zhangyudeiMac:server-psi zhangyu$ git push
Git 最经常使用的操作就是:
工作空间----已修改文件----暂存----提交到本地git---push到远程git
这是一条我们没有特殊需求,没有出现错误和冲突的流程。
1.查看工作空间已修改的文件
git status
example:
zhangyudeiMac:server-psi zhangyu$ git statusOn branch masterYour branch is up-to-date with 'origin/master'.
Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory)
modified: web/Application/Common/Conf/config.php modified: web/Application/Mobile/Controller/PurchaseDetailController.class.php modified: web/Application/Mobile/View/Purchase/purchaseList.html modified: web/Application/Mobile/View/PurchaseDetail/purchaseDetail.html modified: web/Public/Scripts/Mobile/PurchaseDetail/PurchaseDetail.js
no changes added to commit (use "git add" and/or "git commit -a")
2.上个命令我们就可以看出所有修改过的文件,让后我们应该暂存这些文件。
* 单文件暂存
git add "Path(文件路径)" example:
zhangyudeiMac:server-psi zhangyu$ git add web/Application/Mobile/Controller/PurchaseDetailController.class.php
* 暂存全部已修改文件
git add -u
example:
zhangyudeiMac:server-psi zhangyu$ git add -u zhangyudeiMac:server-psi zhangyu$ git status On branch master Your branch is up-to-date with 'origin/master'.
Changes to be committed: (use "git reset HEAD <file>..." to unstage)
modified: web/Application/Common/Conf/config.php modified: web/Application/Mobile/Controller/PurchaseDetailController.class.php modified: web/Application/Mobile/View/Purchase/purchaseList.html modified: web/Application/Mobile/View/PurchaseDetail/purchaseDetail.html modified: web/Public/Scripts/Mobile/PurchaseDetail/PurchaseDetail.js
3.暂存的文件都是要为提交做准备的文件,如果我们有些文件已经暂存了,我们想还原到非暂存怎么办。
git reset "Path(文件路径)"
example: zhangyudeiMac:server-psi zhangyu$ git reset web/Application/Common/Conf/config.php Unstaged changes after reset: M web/Application/Common/Conf/config.php zhangyudeiMac:server-psi zhangyu$ git status On branch master Your branch is up-to-date with 'origin/master'.
Changes to be committed: (use "git reset HEAD <file>..." to unstage)
modified: web/Application/Mobile/Controller/PurchaseDetailController.class.php modified: web/Application/Mobile/View/Purchase/purchaseList.html modified: web/Application/Mobile/View/PurchaseDetail/purchaseDetail.html modified: web/Public/Scripts/Mobile/PurchaseDetail/PurchaseDetail.js
Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory)
modified: web/Application/Common/Conf/config.php
4.最后一步是提交到本地git和push到远程git,估计都会还是贴上吧。
zhangyudeiMac:server-psi zhangyu$ git commit -m "bangdingwuliuadd"
zhangyudeiMac:server-psi zhangyu$ git push
相关文章推荐
- Git学习笔记二(版本回退、工作区和暂存区、撤销修改、删除文件)
- git 取消修改:修改了一些文件,但是并没有commit
- 怎样使用git add命令将当前修改的两个乃至多个文件一次性全部加入暂存区,不包括未跟踪的文件
- Git使用手册/Git教程:找回删除的版本代码/git reflog与git log的区别/取消暂存区文件的暂存
- git(工作区,暂存区,管理修改,撤销修改,删除文件)
- git中取消对文件的修改
- git的文件状态以及git diff结果分析 (staged已暂存的,unstaged取消暂存的)
- Git 教程----3.0时光机穿梭 3.1版本回退 3.2工作区和暂存区 3.3管理修改 3.4撤销修改 3.5删除文件
- Git学习-工作区,暂存区,管理修改,撤销修改,删除文件
- git - 查看已暂存和未暂存的更新以及文件修改之后暂存区、上次提交过的不同
- git 暂存修改文件 stash 命令
- Git学习02 --暂存区,撤销修改,删除文件
- Git取消合并(merge)、暂存修改(stash)、回退到某个版本(reset)的使用方法
- 修改文件后,如何提交到git服务器
- git丢弃本地修改的所有文件(新增、删除、修改)
- Git文件修改和还原
- git-忽略版本控制内某些文件的修改
- Git管理的文件的修改如何撤销?
- git修改代码查看文件差异-移除代码-重命名文件
- phpstorm取消自动保存,修改快捷键并标识修改的文件为星星标记