git常用命令
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了git常用命令,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2015字,纯文字阅读大概需要3分钟。
内容图文
![git常用命令](/upload/InfoBanner/zyjiaocheng/1134/7b0984d31936413783d93ae11b7b93c1.jpg)
对git的命令进行了个简单的总结,以防忘记某个命令的时候回来找找。
git config:列出config命令下的子命令
git config global user.name "":设置全局变量user.name
git config global user.email "";设置全局变量user.email
git config -l或者git config --ls:列出config下已经设置好的变量
git log:查看当前仓库的历史纪录
git status:查看当前working directory的状态
git status -s:简化的git status命令
git的三个状态:
git add hello.py:将 hello.py从working directory提交到staging area.
git clone http://:
git rm hello.py:删除working directory与staging area中hello.py文件。
git rm --cached hello.py:删除staging area中hello.py文件。注:staging area 也叫cache或者index
git mv hello.py hello.txt:重命名working directory与staging area中hello.py文件。相当于下面三个操作:
git rm --cached hello.py -> mv hello.py hello.txt -> git add hello.txt
git commit -m ‘‘:提交staging area到repository(history)。
git commit -am ‘‘:提交working directory到staging area和repository(history)。
git stash:将当前杂乱的working directory中的文件放到 抽屉中,后期可以取出来进行展开。注:这时,working directory,staging area与repository(history)保持一致,还原到最初的状态。
git stash list:将被放到 抽屉 中的working directory列出来。
git stash pop:展开 抽屉 中的working directory,恢复到 抽屉 中的working directory状态。
git diff:查看working directory与staging area的区别。
git diff --staged:查看staging area与repository(history)的区别。
git diff HEAD:working directory与repository(history)的区别。
git diff --stat HEAD:对命令git diff HEAD进行简化
git reset hello.py:用repository(history)的文件来覆盖staging area的文件,达到回滚staging area的目的。
git checkout hello.py:用staging area的文件来覆盖working directory的文件,达到回滚working directory的目的。
git checkout HEAD hello.py:用repository(history)的文件来覆盖working directory的文件,达到回滚working directory的目的。
git commit -a -m ‘add file‘ hello.py或者git commit -am ‘add file‘ hello .py:从working directory直接提交到 repository(history)。注:hello.py必须已经受版本控制的文件,即在之前此文件已经进行过git add的操作。
下面的命令是针对 history(repository)区域的:
history(repository)区域存储的是n个commit对象,每个commit对象又包含两部分,1.tree:此版本下的所有文件,以树的形式,2.parent:指针,指向前一个commit对象。
git cat-file -t HEAD(也可以是commit对象的hashcode):列出HEAD指向的commit对象。
git cat-file -p HEAD(也可以是commit对象的hashcode):直接打开HEAD指向的commit对象。
待续---
原文:http://www.cnblogs.com/westward/p/5770846.html
内容总结
以上是互联网集市为您收集整理的git常用命令全部内容,希望文章能够帮你解决git常用命令所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。