I am currently trying to save some files in a bare git repository, as described here:
https://news.ycombinator.com/item?id=11071754
However, I am trying this with Git for Windows, and not on a Linux machine. The bare git repository gets created, but I am struggling to get the push
working correctly. This is what I have done:
username@hostname MINGW64 ~/Desktop
$ mkdir .myconf
username@hostname MINGW64 ~/Desktop
$ git init --bare "/c/Users/username/Desktop/.myconf"
Initialized empty Git repository in C:/Users/username/Desktop/.myconf/
username@hostname MINGW64 ~/Desktop
$ alias config="git --git-dir='/c/Users/username/Desktop/.myconf' --work-tree='/c/Users/username/Desktop/'"
username@hostname MINGW64 ~/Desktop
$ config config status.showUntrackedFiles no
username@hostname MINGW64 ~/Desktop
$ config status
On branch master
Initial commit
nothing to commit (create/copy files and use "git add" to track)
username@hostname MINGW64 ~/Desktop
$ config add test.txt
username@hostname MINGW64 ~/Desktop
$ config commit -m "Added test file."
[master (root-commit) a587ec1] Added test file.
1 file changed, 1 insertion(+)
create mode 100644 test.txt
Everything so far has worked correctly. However, when I try to push
, this happens:
username@hostname MINGW64 ~/Desktop
$ config push
fatal: No configured push destination.
Either specify the URL from the command-line or configure a remote repository using
git remote add <name> <url>
and then push using the remote name
git push <name>
Also a push
to origin master
does not work:
username@hostname MINGW64 ~/Desktop
$ config push origin master
fatal: 'origin' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Apparently, git wants a push destination.
I have not seen that setting such a destination is a necessary step in the linked description (nor in any derived blog posts), and I am unsure how to do that with Git for Windows. How can this be solved?
You need to define a remote
so Git knows where to push to. The default remote
is called origin
and will be the url for Git to push to.
For example, if you were trying to push to the Linux Kernel the command would be:
git remote add origin https://github.com/torvalds/linux.git