Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I do git-clean with libgit2?

Tags:

libgit2

I want to remove untracked files from the working tree. Like here https://www.kernel.org/pub/software/scm/git/docs/git-clean.html

like image 221
Headless Avatar asked Aug 08 '14 14:08

Headless


People also ask

What is LibGit2Sharp?

LibGit2Sharp brings all the might and speed of libgit2, a native Git implementation, to the managed world of .NET.

Does GIT use libgit2?

libgit2 is used to power Git GUI clients like GitKraken and gmaster and on Git hosting providers like GitHub, GitLab and Azure DevOps.

What is Git clean?

To recap, git clean is a convenience method for deleting untracked files in a repo's working directory. Untracked files are those that are in the repo's directory but have not yet been added to the repo's index with git add .

How to remove files from Git status?

To remove a file from Git, you have to remove it from your tracked files (more accurately, remove it from your staging area) and then commit. The git rm command does that, and also removes the file from your working directory so you don't see it as an untracked file the next time around.


1 Answers

libgit2 doesn't implement this itself. It's a porcelain command, which deals with interaction with the user. It also deals primarily with files which are of no interest to the Git repository.

You can run status to see which files are untracked and then remove whichever ones the version of git-clean would have removed through the usual means available in your programming language.

like image 137
Carlos Martín Nieto Avatar answered Oct 03 '22 20:10

Carlos Martín Nieto