Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

worktree.Add does not add a modified file correctly while git add works as expected #1003

Open
lambou123 opened this issue Jan 16, 2024 · 0 comments

Comments

@lambou123
Copy link

Development environment details:

  • Ubuntu 23.10
  • git 2.40.1
  • go-git v5.11.0

cat ~/.gitconfig

[merge]
   ff = false

I have a modified file (echo "new line" >> readme.txt).

If I run this code, I got a modified file in worktree and index at the same time with the same content.
If I run git add file, this will be added correctly :

r,err := git.PlainOpen(dir)
w, err := r.Worktree()
w.Add(file)

git diff shows no changes:

$ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        modified:   readme.md

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   readme.md

If I run git add file, the output is like that:

$ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        modified:   readme.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant