'Unknown revision or path not in the the working tree error for first push to empty remote
I have a local git repo with many commits. I created an empty repo in github (not initialized with any files).
$ git remote add origin https://github.com/bar/foo.git
$ git push -u origin master
Counting objects: 35, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (35/35), 1.95 KiB | 0 bytes/s, done.
Total 35 (delta 2), reused 0 (delta 0)
remote: Resolving deltas: 100% (2/2), done.
remote: bar/foo
remote: fatal: ambiguous argument 'master': unknown revision or path not in the working tree.
remote: Use '--' to separate paths from revisions, like this:
remote: 'git <command> [<revision>...] -- [<file>...]'
remote: master
To https://github.com/bar/foo.git
* [new branch] master -> master
My changes are in remote and things seem to have worked fine. Still, why do I get a "fatal" error ?
remote: fatal: ambiguous argument 'master': unknown revision or path not in the the working tree.
Solution 1:[1]
Part of the push -u
command failed, but it shouldn't be a problem, it's a separate task. You can now try running:
git branch --set-upstream- master origin/master
or, in newer git versions:
git branch --set-upstream-to master origin/master
to set it manually. Be sure to adjust branch names to those you really used. The first argument here is the name of local branch that will be configured, and the second is the target that push
will now point to by default.
So, in the example above, we're setting local master
to push by default to origin/master
. This is what push -u origin master
would do. If your local repo is OK and if it has 'master' branch, then this command should simply succeed with no errors (and by the way, push-u should have as well back then).
If this command fails, you should review what branches and tracking references and upstreams etc you have configured in your local repo - something will be not right!
Maybe i.e. you don't have 'master' branch locally?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |