$repo->add adds all the files of the repository
Closed this issue · 8 comments
I want to add only one file for my commit not any other.
but when I do as following
$repo = Git::open($path_to_repository);
$repo->add($file_to_add);
$repo->commit($msg);
it added all the modified files to that commit.
Can't confirm this at the moment as I'm out, but the commit method adds the -av flags automatically, which would add all files. Try using ->run('commit ...')
hi,
$repo = Git::open($path_to_repository);
$repo->run("commit $file_to_add");
it hangs
i tried this
$repo = Git::open($path_to_repository);
$repo->run("add $file_to_add");
$repo->commit($msg);
it added all the files.
can you specify what to do specifically?
$repo->run("add $file_to_add");
should be $repo->run("add {$file_to_add}");
. See if that helps.
nothing is working. every time all things are being added.
Okay, let's first determine that the problem is with the library. Run this:
// First, let's be sure what this is
var_dump($file_to_add);
// Make sure that the files aren't already added before we even start
echo $repo->status();
// This should add only the given file
$repo->run('add '.$file_to_add);
// And actually commit the changeset
$repo->run('commit -m "your message"');
Hi,
thanks it worked. thanks for reply :)
It was probably the commit call, like I thought. You can do it this way for now, but I'm going to add an option to the commit method to avoid this in the future.