Configuring and working with git locally seems to be working fine:
~/sb> mkdir proj1
~/sb> cd proj1
~/sb/proj1> echo "asdf" > file1.txt
~/sb/proj1> git init
~/sb/proj1> git add .
~/sb/proj1> git commit -a -m "Import"
~/sb/proj1> git branch
* master
The problem begins when I try to push this to a central repository:
~/sb/proj1> cd /home
~> mkdir temp-repo
~> cd temp-repo/
~/temp-repo> git init --bare
Initialized empty Git repository in /home/temp-repo/
~/temp-repo> cd ~/sb/proj1/
~/sb/proj1> git clone /home/temp-repo/
Cloning into temp-repo...
done.
warning: You appear to have cloned an empty repository.
~/sb/proj1> git push origin master
fatal: 'origin' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
Note: The --bare
and origin master
above were taken from a solution to a problem posted here: pushing to a git repository does not work
Yet, I don't seem to figure out what I am missing. Must be something trivial, but what is it?
UPDATE: The answer by @Firoze Lafeer below works:
~/sb/proj1> cd /home
~> mkdir temp-repo
~> cd temp-repo/
~/temp-repo> git init --bare
Initialized empty Git repository in /home/temp-repo/
~/temp-repo> cd ~/sb/proj1/
~/sb/proj1> git remote add origin /home/temp-repo
~/sb/proj1> git push origin master
Counting objects: 3, done.
Writing objects: 100% (3/3), 230 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
To /home/temp-repo
* [new branch] master -> master
~/sb/proj1>
Now I need to understand why. In particular, what did I misunderstand in this answer which suggests doing a git clone
before git push origin master
.