html tool

2014年4月14日星期一

git log


1.git init //初始化本地库
.git目录的简要说明:
===========================================================
表 1 .git 目录简要说明

子目录名 简要描述
branches Git 项目分支信息,新版 Git 已经不再使用该目录。
config Git 项目配置信息
description Git 项目描述信息
HEAD 指向 Git 项目当前分支的头指针
hooks 默认的"hooks"脚本,被特定事件发生前后触发。
info 里面含一个 exclude 文件,指 Git 项目要忽略的文件。
objects Git 的数据对象,包括:commits, trees, blobs, tags。
refs 指向所有 Git 项目分支的指针
====================================================================
2.git clone 版本库名称 //检出库内容
[针对第二类 Git 仓库,我们不需要 git init 初始化仓库,取而代之的是,使用 git clone 直接将远程镜像克隆到本地仓库。
http://www.ibm.com/developerworks/cn/opensource/os-cn-tourofgit/]
3.//创建用户&mail
[如果是第一次使用 Git,均需要配置用户信息,包括用户名与 Email(如下所示),以便以后每次 Git 提交时都可以自动引用这两条信息,说明是谁更新与提交了代码。http://www.ibm.com/developerworks/cn/opensource/os-cn-tourofgit/ ]
git config --global user.email "usermail@xxx"
git config --global user.name "username"
4.//增加修改到本地缓存
git add filename //add file ,* is ok
git commit -m "xxxx" //提交修改到本地缓存
5.//推送修改到远端库
git push orign master //master为本地要推送的分支名称
add test
[popexizhi:
出现报错如下
-----------------------------------------------------------------------
E:\pc\other\thinking\learning\testgit\gittry>git push origin master
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (5/5), 496 bytes | 0 bytes/s, done.
Total 5 (delta 0), reused 0 (delta 0)
remote: error: refusing to update checked out branch: refs/heads/master
remote: error: By default, updating the current branch in a non-bare repository
remote: error: is denied, because it will make the index and work tree inconsist
ent
remote: error: with what you pushed, and will require 'git reset --hard' to matc
h
remote: error: the work tree to HEAD.
remote: error:
remote: error: You can set 'receive.denyCurrentBranch' configuration variable to

remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into

remote: error: its current branch; however, this is not recommended unless you
remote: error: arranged to update its work tree to match what you pushed in some

remote: error: other way.
remote: error:
remote: error: To squelch this message and still keep the default behaviour, set

remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
To E:/pc/other/thinking/learning/testgit/../gittry
 ! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'E:/pc/other/thinking/learning/testgit/../git
try'
-----------------------------------------------------------------------------
]
[popexizhi:ok,pope常犯的错误命令应该是
git push origin master
自己写成了:git push origin master
]
[参考:http://www.ibm.com/developerworks/cn/opensource/os-cn-tourofgit/]
6.//拉取修改版本
[popexizhi:git 这个很帅,pope执行时提示如下
E:\pc\other\thinking\learning\testgit\xizhi>git push origin master
Password for 'https://popexizhi@code.google.com':
To https://popexizhi@code.google.com/p/xizhi/
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://popexizhi@code.google.com/p/xizh
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
之后直接尝试]
git pull 再次尝试git push origin master 就ok 了。
----------------------------
而要将远程仓库抓取数据到本地,可以使用 git fetch 命令,从而获取所有本地仓库中还没有的数据。
$ git fetch [remote-name]
如果设置了某个分支用于跟踪某个远端仓库的分支,可以使用 git pull 命令自动抓取数据下来,然后将远端分支自动合并到本地仓库中当前分支。从这个角度,git pull 等价于 git fetch + git merge 的功能。
$ git pull [remote-name]
-------------------------------------
[http://www.ibm.com/developerworks/cn/opensource/os-cn-tourofgit/]
====================================================正文结束==================
[popexizhi:
1.log写的好乱,应该找个好方法更新记录结构了:)
2.http://www.ibm.com/developerworks/cn/opensource/os-cn-tourofgit/
IBM的这个内容写的很不错哟,好好阅读一下写写笔记吧
3.popexizhi计划的git使用方案,和其他代码的迁移是否要做thinking
]

没有评论:

发表评论