Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

git push new branch with depth=1 #455

Closed
joshbetz opened this issue Jun 29, 2017 · 8 comments
Closed

git push new branch with depth=1 #455

joshbetz opened this issue Jun 29, 2017 · 8 comments
Labels

Comments

@joshbetz
Copy link
Contributor

Pushing a new branch after cloning with depth=1 doesn't seem to work. I get object not found. The problem seems to be in revlist.Object() -- at least that's where the error happens. As best I can tell, I think it's trying to verify too much of the tree. This same thing works with git:

git clone --depth 1 <repo>
git checkout -b new-branch
touch file
git add file
git commit -m "add test file"
git push
@jucardi
Copy link

jucardi commented Jun 30, 2017

How are you doing the checkout -b ?

@smola
Copy link
Collaborator

smola commented Jun 30, 2017

@joshbetz Thank you for reporting this. We'll look into it.

@smola smola added the bug label Jun 30, 2017
@joshbetz
Copy link
Contributor Author

@smola Thank you! Let me know if you have any questions about reproducing the issue I'm having. I tried debugging it for a while, but couldn't quite follow the logic in remote.Push().

@dirkaholic
Copy link

Hi there,

experiencing the same issue. When going into the respective directory and doing the git push manually using the normal Linux git client afterwards it works. It's the same with another depth used during the clone (tried 2 or 3). So I removed Depth option from the clone command but now the clone command needs a lot more time (which is expected) but also the push after just changing a single file is running veeery long.

@mcuadros
Copy link
Contributor

@joshbetz how are you doing the git checkout -b?

@joshbetz
Copy link
Contributor Author

joshbetz commented Jul 17, 2017

	// local is a *git.Repository
	// Create tmp branch
	ref, err := local.Head()
	new := plumbing.NewReferenceFromStrings("refs/heads/branch-name", ref.Hash().String())
	err = local.Storer.SetReference(new)
	if err != nil {
		return err
	}

	// w is the local.Worktree()
	err = w.Checkout(&git.CheckoutOptions{Branch: plumbing.ReferenceName("refs/heads/branch-name")})
	if err != nil {
		return err
	}

@dirkaholic
Copy link

dirkaholic commented Jul 24, 2017

Thanks for fixing the issue. What do you think @mcuadros when it can be pushed to the v4 branch ?

@mvpmvh
Copy link

mvpmvh commented Aug 11, 2019

was this actually fixed? i'm getting the same issue when doing a shallow fetch, followed by a push.
The push fails with the same unpack error: error Missing unknown <commit_sha>

go-git version gopkg.in/src-d/go-git.v4 v4.13.1

err := remote.FetchContext(fetchCtx, &git.FetchOptions{
		RemoteName: github,
		RefSpecs:   []config.RefSpec{config.RefSpec(fetchRefSpec)},
		Auth: &githttp.BasicAuth{
			Username: gitParams.User, // yes, this can be anything except an empty string
			Password: gitParams.Password,
		},
		Progress: os.Stdout,
		Tags:     git.NoTags,
		Depth:    1,
	})

...

err := remote.PushContext(pushCtx, &git.PushOptions{
		RemoteName: google,
		RefSpecs:   []config.RefSpec{config.RefSpec(pushRefSpec)},
		Progress:   os.Stdout,
	})

results in unpack error: error Missing unknown f898934722070d9b6387685402fbd184de6ea3ce

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
Projects
None yet
Development

No branches or pull requests

6 participants