您的位置:首页 > 其它

git使用总结

2013-07-09 20:11 387 查看
1:git分支1)查看当前的远程库$git remote -v2)push分支到服务器,如果你有个叫serverfix的分支需要和他人一起开发,可以运行git push (远程仓库名) (分支名)$git push origin serverfix接下来,当你的协作者再次从服务器上获取数据时,他们将得到一个新的远程分支origin/serverfix:$ git fetch origin$ git chechout serverfix2:新建标签a)创建一个含附注类型的标签非常简单,用
-a
(译注:取
annotated
的首字母)指定标签名字即可:$ git tag -a v1.0 -m 'update to v1.0'而
-m
选项则指定了对应的标签说明,Git会将此说明一同保存在标签对象中。如果没有给出该选项,Git 会启动文本编辑软件供你输入标签说明。b)可以使用
git
show
命令查看相应标签的版本信息,并连同显示打标签时的提交对象。$git show v1.3我们可以看到在提交对象信息上面,列出了此标签的提交者和提交时间,以及相应的标签说明。c)轻量级标签轻量级标签实际上就是一个保存着对应提交对象的校验和信息的文件。要创建这样的标签,一个
-a
-s
-m
选项都不用,直接给出标签名字即可$ git tag v1.4-lw$ git tagv1.2v1.3v1.4-lw3:Git中的着色$ git config --global color.ui true设置好以后,当输出到终端时,Git 会为之加上颜色4:恢复删除文件$ git checkout 47a08b4a7b38ab963dade11e024839fd396e7423 -- device/amlogic/PI3100_93/mali.ko5:比较2个分支目录$git diff T852..T852-SBK frameworks6.
刚配置好的git仓库服务器,首次提交的时候会报如下错误:
remote: error: refusing to update checked out branch: refs/heads/master
[/code]
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 inconsistent remote: error: with what you pushed, and will require 'git reset --hard' to match
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: To squelch this message and still keep the default behaviour, set remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'. To ... ! [remote rejected] master -> master (branch is currently checked out) error: failed to push some refs to
需要配置一下git的接收配置,执行如下命令即可正确提交:
# git config receive.denyCurrentBranch ignore
7:查看某次commit的详细记录,包括修改了哪些文件,该文件修改了哪些地方# git show 7b0778531938e3fffb7a416e9f48c21c0785f5868:恢复到某次的commit# gitcheckout c039249d5085ff301a742a07230e1f3e1748acb8 -- device/amlogic/MID30801/version_id.mk# gitadd device/amlogic/MID30801/version_id.mk# gitcommit -m 'AP6476恢复wl212'
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: