I can't seem to push on 0.5 nor 0.6. Everything up to the push works fine.
I've also tried manually passing the remote url and setting force=true
but they both return 0 and do nothing.
Reproducing:
[ ~ ]
➣ git clone https://github.com/christopher-dG/TestPkg.jl
Cloning into 'TestPkg.jl'...
remote: Counting objects: 12, done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 12 (delta 0), reused 12 (delta 0), pack-reused 0
Unpacking objects: 100% (12/12), done.
[ ~ ]
➣ cd TestPkg.jl
[ ~/TestPkg.jl ]
➣ touch x
[ ~/TestPkg.jl ]
➣ julia-0.6
_
_ _ _(_)_ | A fresh approach to technical computing
(_) | (_) (_) | Documentation: http://docs.julialang.org
_ _ _| |_ __ _ | Type "?help" for help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 0.6.0-dev.2899 (2017-02-22 04:15 UTC)
_/ |\__'_|_|_|\__'_| | Commit 61a291b (0 days old master)
|__/ | x86_64-apple-darwin13.4.0
julia> repo = LibGit2.GitRepo(pwd())
LibGit2.GitRepo("/Users/degraafc/TestPkg.jl")
julia> LibGit2.add!(repo, "x")
julia> LibGit2.commit(repo, "test")
GitHash("5e5586d6f2275982fb7e0aa62b0299c3ca27fd73")
julia> LibGit2.push(repo)
Username for 'https://github.com':christopher-dg
Password for 'https://[email protected]':
0
shell> git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)
nothing to commit, working tree clean
julia> versioninfo(true)
Julia Version 0.6.0-dev.2899
Commit 61a291b (2017-02-22 04:15 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin13.4.0)
CPU: Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz
WORD_SIZE: 64
uname: Darwin 16.4.0 Darwin Kernel Version 16.4.0: Thu Dec 22 22:53:21 PST 2016; root:xnu-3789.41.3~3/RELEASE_X86_64 x86_64 i386
Memory: 16.0 GB (5547.1171875 MB free)
Uptime: 18672.0 sec
Load Avg: 1.6396484375 2.03173828125 1.9072265625
Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz:
speed user nice sys idle irq
#1 2700 MHz 17380 s 0 s 5615 s 160949 s 0 s
#2 2700 MHz 413 s 0 s 322 s 183199 s 0 s
#3 2700 MHz 14461 s 0 s 3368 s 166105 s 0 s
#4 2700 MHz 414 s 0 s 319 s 183201 s 0 s
#5 2700 MHz 14444 s 0 s 3380 s 166110 s 0 s
#6 2700 MHz 415 s 0 s 324 s 183195 s 0 s
#7 2700 MHz 14303 s 0 s 3325 s 166306 s 0 s
#8 2700 MHz 423 s 0 s 322 s 183189 s 0 s
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, skylake)
Environment:
XPC_FLAGS = 0x0
PATH = /Applications/Julia-0.6.app/Contents/Resources/julia/bin:/usr/local/bin:/Applications/Julia-0.5.app/Contents/Resources/julia/bin:/usr/local/bin:/Applications/Julia-0.6.app/Contents/Resources/julia/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
TERM = xterm-256color
HOME = /Users/degraafc
WORKON_HOME = /Users/degraafc/.virtualenvs
PROJECT_HOME = /Users/degraafc/Code
FONTCONFIG_PATH = /Applications/Julia-0.6.app/Contents/Resources/julia/etc/fonts
Package Directory: /Users/degraafc/.julia/v0.6
INFO: Initializing package repository /Users/degraafc/.julia/v0.6
INFO: Cloning METADATA from https://github.com/JuliaLang/METADATA.jl
No packages installed
Do you have GitHub 2FA set up, and have you confirmed that origin
is a valid remote name in the cloned repo?
I do not have 2FA on my GitHub account, and origin is a valid remote. Pushing from the command line after ending the Julia session works fine, so I know that the commit is definitely not an issue.
Welp, I'm out of ideas then. I'm inclined to call this a bug.
I'm having the exact same problem, not 2FA, push exits with a 0, push works from the command line. I thought I was just being an idiot so it's good to see it's not just me.
Apparently you need to manually specify at least 1 refspec, e.g.
LibGit2.push(repo, refspecs=["refs/heads/master"])
will push the master branch.
This whole interface probably needs redesigning as part of #19839, but in the meantime we should at least document this.
I'm not familiar with code, but couldn't making refspecs=["refs/heads/master"]
be the default be at least a short term fix?
I think a better solution would be for it to default to the current branch. Thoughts? I can make a PR for that + documentation.
The behaviour of CLI git
is determined by the push.default
config option. If we're going to change behaviour, I would prefer that we follow that.
That's a good idea. Is there a simple way to pass that value somewhere and have it do the work of figuring out how to behave, or do I need to do that myself?
I don't think so, unfortunately (or at least, I couldn't find it).
Oh well, I'll see what I can come up with.
I think I can fix this tonight or at least make it more convenient.
Did https://github.com/JuliaLang/julia/pull/21227 fix this?
You can add information about the push refspecs in two other ways: by setting
an option in the repository'sGitConfig
(withpush.default
as the key) or
by callingadd_push!
. Otherwise you will need to explicitly specify
a push refspec in the call topush
for it to have any effect, like so:
LibGit2.push(repo, refspecs=["refs/heads/master"])
.
So as I understand it, I should be able to write LibGit2.push(repo)
if push.default
is set, but this is not working for me. I'm on the latest master
as of this morning.
[ ~/test ] git status [ master ]
On branch master
Your branch is ahead of 'origin/master' by 2 commits.
(use "git push" to publish your local commits)
nothing to commit, working tree clean
[ ~/test ] git config push.default [ master ]
simple
[ ~/test ] git branch -vv [ master ]
* master 237e516 [origin/master: ahead 2] test
[ ~/test ] julia-dev [ master ]
_
_ _ _(_)_ | A fresh approach to technical computing
(_) | (_) (_) | Documentation: http://docs.julialang.org
_ _ _| |_ __ _ | Type "?help" for help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 0.6.0-pre.beta.11 (2017-04-03 14:43 UTC)
_/ |\__'_|_|_|\__'_| | Commit daefda40aa (0 days old master)
|__/ | x86_64-apple-darwin16.4.0
julia> repo = LibGit2.GitRepo(pwd())
LibGit2.GitRepo("/Users/degraafc/test")
julia> LibGit2.push(repo)
Passphrase for /Users/degraafc/.ssh/id_rsa:
0
julia> exit()
[ ~/test ] git status [ master ]
On branch master
Your branch is ahead of 'origin/master' by 2 commits.
(use "git push" to publish your local commits)
nothing to commit, working tree clean
Afterwards, I tried using the add_push!
method which worked.
Am I doing the first method incorrectly?
Well, I'm glad my code works...
You might try setting a GitConfig
variable push.default
for the GitRepo
itself?
[ ~/test ] git init; git remote add origin https://github.com/christopher-dg/test; touch a; git add a; git commit -m 'a'; git push origin master -u -f
Initialized empty Git repository in /Users/degraafc/test/.git/
[master (root-commit) 3d927bb] a
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 a
Enter passphrase for key '/Users/degraafc/.ssh/id_rsa':
Counting objects: 3, done.
Writing objects: 100% (3/3), 202 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To ssh://github.com/christopher-dg/test
+ d95262a...3d927bb master -> master (forced update)
Branch master set up to track remote branch master from origin.
[ ~/test ] git branch -vv [ master ]
* master 3d927bb [origin/master] a
[ ~/test ] git config push.default [ master ]
[ ~/test ] julia-dev [ master ]
_
_ _ _(_)_ | A fresh approach to technical computing
(_) | (_) (_) | Documentation: http://docs.julialang.org
_ _ _| |_ __ _ | Type "?help" for help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 0.6.0-pre.beta.11 (2017-04-03 14:43 UTC)
_/ |\__'_|_|_|\__'_| | Commit daefda40aa (0 days old master)
|__/ | x86_64-apple-darwin16.4.0
julia> repo = LibGit2.GitRepo(pwd())
LibGit2.GitRepo("/Users/degraafc/test")
julia> cfg = LibGit2.GitConfig(repo)
Base.LibGit2.GitConfig(Nullable{Base.LibGit2.GitRepo}(LibGit2.GitRepo("/Users/degraafc/test")), Ptr{Void} @0x00007f9c0a10d030)
julia> LibGit2.set!(cfg, "push.default", "simple")
0
julia> LibGit2.getconfig(repo, "push.default", "")
"simple"
shell> git config push.default
simple
shell> git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working tree clean
julia> touch("b")
Base.Filesystem.File(false, RawFD(-1))
julia> LibGit2.add!(repo, "b")
julia> LibGit2.commit(repo, "b")
GitHash("6335a05e598e210d48914501f729104d7fb55427")
shell> git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)
nothing to commit, working tree clean
julia> LibGit2.push(repo)
Passphrase for /Users/degraafc/.ssh/id_rsa:
0
No luck 😞
Weird. I'll see if I can figure this out but if you want to open a PR to fix the docs go ahead.
Also, do you think this has been resolved sufficiently to close?
Definitely, any further discussion on how to make it better/more user friendly is unrelated to my 'this doesn't work!!!!' complaint :smile:
Great, glad I managed to help.
Most helpful comment
The behaviour of CLI
git
is determined by thepush.default
config option. If we're going to change behaviour, I would prefer that we follow that.