使用 git 命令行实现 commit 到 bare 仓库
2014-03-24 10:41
851 查看
这是一个shell脚本,可以直接执行,观察它的输出,然后再去检查bare仓库,看看结果是否正确。
#!/bin/sh cd ~ rm -rf bare.git echo "-------> create bare repo" echo "" git init --bare bare.git cd bare.git echo "" echo "-------> initial commit: test.txt" echo "" # create object obj=`echo 'test content' | git hash-object -w --stdin` # create index git update-index --add --cacheinfo 100644 $obj test.txt # create tree tree=`git write-tree` git ls-tree $tree echo "" # commit commit=`echo 'initial commit' | git commit-tree $tree` git log --stat --pretty=oneline $commit echo "" echo "-------> second commit: new.txt" echo "" # second commit obj1=`echo 'new content' | git hash-object -w --stdin` git update-index --add --cacheinfo 100644 $obj1 new.txt tree1=`git write-tree` git ls-tree $tree1 echo "" commit1=`echo 'second commit' | git commit-tree $tree1 -p $commit` # create refs git update-ref refs/heads/master $commit1 # update head git symbolic-ref HEAD refs/heads/master git log --stat --pretty=oneline HEAD echo "" echo "-------> third commit: edit test.txt" echo "" # delete index rm index # create index from HEAD git read-tree HEAD obj2=`echo 'edited test content' | git hash-object -w --stdin` git update-index --cacheinfo 100644 $obj2 test.txt tree2=`git write-tree` git ls-tree $tree2 echo "" commit2=`echo 'third commit' | git commit-tree $tree2 -p $commit1` # update refs git update-ref refs/heads/master $commit2 git log --stat --pretty=oneline HEAD
相关文章推荐
- 为什么初始化远程仓库要使用git init --bare
- Git的使用之下载仓库(folk)传送(commit)
- OS(关于版本控制)使用git 创建远程仓库-熟知这些命令行,带你装逼带你飞!
- git个人使用总结 —— idea命令行、撤销commit (未完待续)
- svn与git区别简介,git分支操作在mac客户端soureTree和使用命令行如何实现
- Git开发时多分支防止多次提交版本线,使用cherry-pick、合并commit实现多次修改关联iusses
- 02_创建Git仓库,克隆仓库,git add,git commit,git push,git pull,同行冲突,不同行冲突的结局方案,git mergetool的使用
- 02_创建Git仓库,克隆仓库,git add,git commit,git push,git pull,同行冲突,不同行冲突的结局方案,git mergetool的使用
- git的使用方法:回退本次commit,提交代码到另一个远程仓库,修改远程仓库地址
- 【Eclipse中使用Git之二】Commit代码到本地仓库
- git的使用(一)---建立本地仓库、add和commit、status和git diff、版本回退使用git reset
- git 基本使用,初始化本地仓库,创建文件,add文件,commit文件,git版本穿梭
- Nexus OSS 3 搭建并配置使用 Docker & Git LFS 仓库
- Git 基础 - 远程仓库的使用
- 使用git命令将本地项目推送到远程仓库
- jenkins 使用git仓库部署 报错:jenkins Error performing command: git ls-remote -h
- 第一次使用git,撤销git add操作 (undo git add before commit)
- 从Git仓库中恢复已删除的分支、文件或丢失的commit[转]
- 使用git建立远程仓库,让别人git clone下来