I want to have a git repository accessed via ssh. Just for me, no plans to give anyone else access.
Below is the transcript of what I did, how do I solve the problem at the end of git refusing to update a checked out branch?
rjc@linux:/tmp$ mkdir orig
rjc@linux:/tmp$ cd orig
rjc@linux:/tmp/orig$ git init
Initialized empty Git repository in /tmp/orig/.git/
rjc@linux:/tmp/orig$ ls -al > file
rjc@linux:/tmp/orig$ git add file
rjc@linux:/tmp/orig$ git commit file
[...]
1 file changed, 5 insertions(+)
create mode 100644 file
rjc@linux:/tmp/orig$ cd ..
rjc@linux:/tmp$ mkdir copy
rjc@linux:/tmp$ cd copy
rjc@linux:/tmp/copy$ git init
Initialized empty Git repository in /tmp/copy/.git/
rjc@linux:/tmp/copy$ git pull localhost:/tmp/orig
remote: Counting objects: 3, done.
[...]
From localhost:/tmp/orig
* branch HEAD -> FETCH_HEAD
rjc@linux:/tmp/copy$ git push localhost:/tmp/orig
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream localhost:/tmp/orig master
rjc@linux:/tmp/copy$ git push --set-upstream localhost:/tmp/orig master
Branch 'master' set up to track remote branch 'master' from 'localhost:/tmp/orig
'.
Everything up-to-date
rjc@linux:/tmp/copy$ ls -al > file2
rjc@linux:/tmp/copy$ git add file2
rjc@linux:/tmp/copy$ git commit file2
[master 3825986] s
Committer: Russell Coker <rjc@aaa.coker.com.au>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly. Run the
following command and follow the instructions in your editor to edit
your configuration file:
git config --global --edit
After doing this, you may fix the identity used for this commit with:
git commit --amend --reset-author
1 file changed, 6 insertions(+)
create mode 100644 file2
rjc@linux:/tmp/copy$ git push
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 369 bytes | 369.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: error: refusing to update checked out branch: refs/heads/master
remote: error: By default, updating the current branch in a non-bare repository
remote: is denied, because it will make the index and work tree inconsistent
remote: with what you pushed, and will require 'git reset --hard' to match
remote: the work tree to HEAD.
remote:
remote: You can set the 'receive.denyCurrentBranch' configuration variable
remote: to 'ignore' or 'warn' in the remote repository to allow pushing into
remote: its current branch; however, this is not recommended unless you
remote: arranged to update its work tree to match what you pushed in some
remote: other way.
remote:
remote: To squelch this message and still keep the default behaviour, set
remote: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
To localhost:/tmp/orig
! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'localhost:/tmp/orig'
--
My Main Blog http://etbe.coker.com.au/
My Documents Blog http://doc.coker.com.au/