Reputation: 880
Following this(Best way to handle offline and online development with Git) question, I decided to give it a try and use a pendrive as my remote. But I may be missing something because I can't commit the changes.
I have a repository called 'arvores' in a directory in the pendrive, which I cloned from github.com.
Now, I have another local directory and I cloned the pendrive's directory.
$ git clone f:/pendrive/arvores
Cloning into 'arvores'...
done.`
Then I changed one single file to test if I could push and commit changes, but I get this error message.
$ git add .htaccess
$ git commit
[master 40eeccf] teste
1 file changed, 9 deletions(-)
$ git push
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:
git config --global push.default matching
To squelch this message and adopt the new behavior now, use:
git config --global push.default simple
See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 283 bytes | 0 bytes/s, done.
Total 3 (delta 2), 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: error: is denied, because it will make the index and work tree inconsistent
remote: error: with what you pushed, and will require 'git reset --hard' to match
remote: error: the work tree to HEAD.
remote: error:
remote: error: You can set 'receive.denyCurrentBranch' configuration variable to
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into
remote: error: its current branch; however, this is not recommended unless you
remote: error: arranged to update its work tree to match what you pushed in some
remote: error: other way.
remote: error:
remote: error: To squelch this message and still keep the default behaviour, set
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
To f:/pendrive/arvores
! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'f:/pendrive/arvores'
Upvotes: 2
Views: 1555
Reputation: 2605
You have two options as far as I can see:
Clone a bare repo from github onto your pendrive and then clone this repo as normal on to your work machine (as Bruno Nova and others have already suggested.)
Clone the repo to your pendrive as you have done but don't clone it on your work machine. Just plug it in and use the working directory on the the directory on the pendrive.
The second options is a suggested workflow in the question you linked to.
Upvotes: 1
Reputation:
Like knittl said, the problem is that the repository in the pendrive is not bare, and you can't push changes to non-bare repositories (by default).
In the pendrive, you should have executed:
git clone --bare github_repo
That clones github_repo into a bare repository. You will then be able to clone and push from/to that repository normally.
You should probably investigate and learn how git works. Especially about bare and non-bare repositories.
A bare repository is not an empty repository. It's a repository without a "working tree".
When you run git clone repo
(non-bare), you'll see in the created folder not only the
files of the last commit (i.e. the working tree), but also a hidden ".git" folder.
That folder contains the entire repository (all commits, branches, tags, ...).
When you run git clone --bare repo
(bare), you'll get only that ".git" folder
(no working tree).
Upvotes: 3