git clone [-b 分支名] chenlong@
不带-b参数默认master分支
git clone git clone –progress -v
git.exe clone –progress -v “” “\\192.168.0.105\www\other_user\chenlong\admin”
设置 -> git 编辑本地 .git/config 增加[credential]helper = store
git clone @ admin2
git checkout — application/core/MY_Exceptions.php
git reset HEAD(commit) file
git reset –hard HEAD~3会将最新的3次提交全部重置,就像没有提交过一样。
git reset 版本号 — b.txt
在Windows平台下面就有这个该死的行分隔符的问题,一般推荐
git config –global core.autocrlf false另外还可以
git config –global core.safecrlf true保证文件的行分隔符不会混杂。 然后以防万一重新git checkout或者git reset –hard一下
================================================================================================================================查看blobgit show 6ff87c4664 查看blob
查看树git ls-tree fb3a8bdd0ce 查看tree注意:所有的文件的mode位都是644 或 755,这意味着Git只关心文件的可执行位.
查看某个提交git show -s –pretty=raw 2be7fcb476
查看taggit cat-file tag v1.5.0
每个目录都创建了 tree对象 (包括根目录), 每个文件都创建了一个对应的 blob对象 . 最后有一个 commit对象 来指向根tree对象(root of trees), 这样我们就可以追踪项目每一项提交内容.一个commit包含一个tree父对象 (parent(s))作者author提交者committer
|– HEAD # 这个git项目当前处在哪个分支里|– config # 项目的配置信息,git config命令会改动它|– description # 项目的描述信息|– hooks/ # 系统默认钩子脚本目录|– index # 索引文件|– logs/ # 各个refs的历史信息|– objects/ # Git本地仓库的所有对象 (commits, trees, blobs, tags)`– refs/ # 标识你项目里的每个分支指向了哪个提交(commit)。
.git/refs/heads/master
.git/refs/remotes/origin/master
//add了没有commitChanges to be committed:(use “git reset HEAD…” to unstage)
new file: yyy
//原来的文件修改了 没有addChanges not staged for commit:(use “git add …” to update what will be committed)(use “git checkout –…” to discard changes in working directory)
modified: test
//新文件没有add过的Untracked files:(use “git add…” to include in what will be committed)
xxx
git config –global user.name “Scott Chacon”git config –global user.email “schacon@gmail.com”
Clone一个仓库git clone [dir]
初始化一个新的仓库git init
除了用git add 命令,我还可以用$ git commit -a这会自动把所有内容被修改的文件(不包括新创建的文件)都添加到索引中,并且同时把它们提交。相当于add + commit
Git跟踪的是内容不是文件git add 不但是用来添加不在版本控制中的新文件,也用于添加已在版本控制中但是刚修改过的文件;在这两种情况下, Git都会获得当前文件的快照并且把内容暂存(stage)到索引中,为下一次commit做好准备。
例如:修改了test ,git add 后 看Changes to be committed:modified: mmm
再修改test git status看Changes to be committed:modified: mmm
Changes not staged for commit:modified: mmm
分支与合并@基础查看当前分支git branch创建git branch test切换到某个分支git checkout branch合并git merge test
Git鼓励大量使用分支:
查看分支:git branch
创建分支:git branch name
切换分支:git checkout name
创建+切换分支:git checkout -b name
合并某分支到当前分支:git merge name 合并后的操作2个分支看起来都是一样的
删除分支:git branch -d name
修改的还没add的为 a版本,修改了add了的为 index版本,已经commit过的为 c版本,已经push的为 r版本。
git diff来找你当前工作目录和上次提交与本地索引间的差异 (即a版本和c版本)git diff –cached看在下次提交时要提交的内容(staged,添加到索引中) (即index版本和c版本)
git diff master..testgit diff master…test 比父分支
.gitignore 忽略文件不提示在Untracked files里
git stash 存储某个时间状态
Git的撤消操作 – 重置, 签出 和 撤消
===================================9.24==================================================================版本回退(未push出去之前):
首先,Git必须知道当前版本是哪个版本,在Git中,用HEAD表示当前版本,也就是最新的提交“ 3628164…882e1e0”(注意我的提交ID和你的肯定不一样),上一个版本就是HEAD^,上上一个版本就是HEAD^^,当然往上100个版本写100个^比较容易数不过来,所以写成HEAD~100。
$ git reset –hard HEAD^HEAD is now at ea34578 add distributed
日志 git log 会清除掉
又想回到最新的 git reflog查看历史 找到最新的 id再回来$ git reset –hard 3628164HEAD is now at 3628164 append GPL
命令git checkout — readme.txt意思就是,把readme.txt文件在工作区的修改全部撤销,这里有两种情况:一种是readme.txt自修改后还没有被放到暂存区,现在,撤销修改就回到和版本库一模一样的状态;一种是readme.txt已经添加到暂存区后,又作了修改,现在,撤销修改就回到添加到暂存区后的状态。总之,就是让这个文件回到最近一次git commit或git add时的状态。
懂得倾听别人的忠告。