Git grit,如何直接修改 git 库中的文件?

zhaoguobin · February 06, 2012 · Last by zhaoguobin replied at February 06, 2012 · 3298 hits

今天突然发现了 grit,可以轻易操纵 git 库。 于是从网上抄了一小段程序。

# create Repo
r = Repo.init_bare 'myrepo.git'
i = r.index

# first commit to master
i.add('myfile.txt', 'my file contents')
i.commit("This is my commit")

我突然产生一种很邪恶的想法,如何直接修改myfile.txt中的内容? 请各位大神赐教!!!

i.add('myfile.txt', 'my new file contents')

@vkill 是新建了一个文件,还是修改了文件的内容,不确定。有空我试试!

git 储存的都是 delta。

所谓“新建文件”就是从没有到有的修改

@vkill @hayeah 貌似不对啊,好像产生的是新文件,旧文件的提交记录找不到了!!!

@vkill @hayeah 原来是对的,是 commit 的原因,学习了!!!

You need to Sign in before reply, if you don't have an account, please Sign up first.