我正在初始化一个已经有一些文件的 git 存储库
repo = Rugged::Repository.init_at(".")
我需要暂存该文件夹中已有的文件并提交它们。这是我尝试过的:
repo = Rugged::Repository.new(".")
index = repo.index
index.add_all()
options = {}
options[:tree] = index.write_tree(repo)
options[:author] = { :email => "testuser@github.com", :name => 'Test Author', :time => Time.now }
options[:committer] = { :email => "testuser@github.com", :name => 'Test Author', :time => Time.now }
options[:message] ||= "Making a commit via Rugged!"
options[:parents] = repo.empty? ? [] : [ repo.head.target ].compact
options[:update_ref] = 'HEAD'
Rugged::Commit.create(repo, options)
但是,如果我查看目录并运行,git status
我得到的是:
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
deleted: .editorconfig
deleted: .gitignore
deleted: Procfile
deleted: README.md
Untracked files:
(use "git add <file>..." to include in what will be committed)
.editorconfig
.gitignore
Procfile
README.md