I'm attempting to create a remote git repo, (which I initialized with the --bare
option) and push some source files to it.
I have a local git repo and a bare remote:
ubuntu@ip-LOCAL-IP:~/notebooks$ cat .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[branch "master"]
[remote "nbcsm"]
url = ssh://[email protected]/home/ubuntu/notebooks/.git
fetch = +refs/heads/*:refs/remotes/nbcsm/*
I created the local repo with:
1. git init
2. git add *.ipynb
3. `git commit -m "first import of IPython Notebooks"
I then verified that my local repo has tracked files in it by using vi to edit an *.ipynb file and then running git status
. git does see the changed file.
However, when I execute git push nbcsm master
the push appears to be successful but the target directory on my remote computer/instance is empty (i.e. it doesn't contain the files I'm trying to push to the remote):
ubuntu@ip-LOCAL-IP:~/notebooks$ git push nbcsm master
Enter passphrase for key '/home/ubuntu/.ssh/id_rsa':
Counting objects: 11, done.
Compressing objects: 100% (9/9), done.
Writing objects: 100% (9/9), 2.49 KiB, done.
Total 9 (delta 5), reused 0 (delta 0)
To ssh://[email protected]/home/ubuntu/notebooks/.git
7a50f44..295a4fa master -> master
ubuntu@ip-LOCAL-IP:~/notebooks$
Verifying that the files aren't on remote:
ubuntu@ip-LOCAL-IP:~/notebooks$ ssh [email protected]
Enter passphrase for key '/home/ubuntu/.ssh/id_rsa':
Welcome to Ubuntu 12.04 LTS (GNU/Linux 3.2.0-25-virtual x86_64)
* Documentation: https://help.ubuntu.com/
System information as of Tue Dec 18 16:46:23 UTC 2012
System load: 0.02 Processes: 63
Usage of /: 41.7% of 7.97GB Users logged in: 0
Memory usage: 12% IP address for eth0:REMOTE-IP
Swap usage: 0%
Graph this data and manage this system at https://landscape.canonical.com/
Get cloud support with Ubuntu Advantage Cloud Guest
http://www.ubuntu.com/business/services/cloud
*** /dev/xvda1 will be checked for errors at next reboot ***
ubuntu@REMOTE-IP:~$ sudo find /home/ubuntu/ -name "*.ipynb"
/home/ubuntu/notebooks/Untitled0.ipynb
ubuntu@ip-REMOTE-IP:~$
There are about 12 *.ipynb files in the local repo that are not being pushed. I'm fairly certain that this is a conceptual issue rather than a syntax issue but I've read and re-read the Remote chapter in the O'Reilly Git book and I'm stumped.
git push
will not, unless you explicitly tell it to via one of the hook scripts, update the working directory on the remote end. Usually, if the branch you have checked out on the remote end is one of the branches you are pushing, it will complain loudly and refuse the push. However, that warning can be disabled, allowing you to push, but it still won't update the working directory. You can either run git reset --hard HEAD
in your remote repository (or git checkout master
or something similar), or set up a post-receive
hook to do that for you or something. It's probably better to have the remote repository be bare, though - possibly introducing a third repository so that your development repo can push there, and your production repo can pull from it.
Edit: Ok, now this is a different question, since you mention your remote repository was created with --bare
. If your remote repository is bare, then you should not expect to see your files there in a "normal" way, because a bare repository does not have a working directory associated with it. Instead you'll see a few subdirectories (like branches
, hooks
, info
, objects
and refs
) and files (config
, description
, HEAD
) that you would normally see under .git
in a non-bare repository. You should still be able to run git log
and other commands (like git show HEAD:<some_file>
) to verify that your data is there, though.
git status
that git sees the file changed.
git status
should tell you that no file is being modified!
git status
# On branch master
nothing to commit (working directory clean)
If it lists modified files, you need to add and commit those files first, before pushing:
git add .
git commit -m "my commit message"
git push -u nbcsm master
Plus, make sure and check what branch is checked out on the server side:
cd /home/ubuntu/notebooks
git branch
You shouldn't be able to push to a non-bare repo without a warning.
But since you didn't have one, it is possible that another branch is checked out.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With