From: sylvain@saboua.me Subject: Re: git add equivalent – add only selected files To: Stefan Sperling Cc: gameoftrees@openbsd.org Date: Thu, 06 Mar 2025 12:41:05 +0100 I incepted my worktree by following some reddit's user advice which had worked for me a few years ago when I started rfdupes: https://www.reddit.com/r/openbsd/comments/1b7wl8h/ The trouble is very simple, for a start : how is `got' supposed to know where to look for a repository to add the files to ? The error is the following: $ pwd /var/www/got/public/saboua.xyz $ got add /var/www/htdocs/saboua.xyz/doc/*.css got: 'got add'needs a work tree in addition to a git repository Work trees can be checked out from this Git repository with 'got checkout'. The got(1) manual page contains more information. On 2025-03-06 10:10, Stefan Sperling wrote: > On Thu, Mar 06, 2025 at 05:41:24AM +0100, Sylvain wrote: >> Prior to putting my website source code in a got repo for public >> display, I performed a little trick involving mainly mv commands in >> order to trim my website's folder of irrelevant content, which I >> restored afterwards. >> >> I neglected to add the *.css files, located in /doc along with a bunch >> of other documents. Is there a command to commit those files, and only >> those files, to the repo ? >> >> My ~/.history file has several got checkout -p doc [...] attempts that >> failed. > > Hmm. 'got add' is indeed the command you should be using. > I don't see anything wrong with your general approach. > > Generally, adding files involves checking out a work tree (with or > without > the -p option, it doesn't really matter), then putting new files into > this > work tree and running 'got add' on them, i.e. passing the file paths > you > want to add to 'got add'. > 'got status' should then show the relevant files in 'A' status. > Now run 'got commit' to commit the new files. This also accepts > filenames > on the command line in case you want to limit the commit to specific > files > while other unrelated changes are sitting in the same work tree. > > Since you were asking for an equivalent to 'git add': Git's add command > also performs staging functionality. Got has a separate command for > this > called 'got stage'. You can optionally use that too, but it is not > necessary > at all in this trivial use case. > > So there is nothing super complicated about adding new files, and it > seems > you were intending to perform the required steps correctly. > > Except for some reason the checkout -p command ran into an error, so > you > couldn't get a work tree. What was the error message?