How to create a bare repository on windows file system


mkdir GitRepoBare.git

cd GitRepoBare.git

git --bare init

cd ..

git clone ./GitRepoBare.git GitRepoClone

cd GitRepoClone

That completes the creating and cloning part. Now lets try to create some content in clone and push it to Bare.

gundlapa@MARS-ROVER ~/GitRepoClone (master)
$ cat>temp.text
asdf

gundlapa@MARS-ROVER ~/GitRepoClone (master)
$ git add *

gundlapa@MARS-ROVER ~/GitRepoClone (master)
$ git commit -m 'testing'
[master (root-commit) 7fe023c] testing
 1 file changed, 1 insertion(+)
 create mode 100644 temp.text

gundlapa@MARS-ROVER ~/GitRepoClone (master)
$ git status
On branch master
Your branch is based on 'origin/master', but the upstream is gone.
  (use "git branch --unset-upstream" to fixup)

nothing to commit, working directory clean

gundlapa@MARS-ROVER ~/GitRepoClone (master)
$ git remote -v
origin  c:/Users/gundlapa/GitRepoBare.git/ (fetch)
origin  c:/Users/gundlapa/GitRepoBare.git/ (push)

gundlapa@MARS-ROVER ~/GitRepoClone (master)
$ 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

When push.default is set to 'matching', git will push local branches
to the remote branches that already exist with the same name.

In Git 2.0, Git will default to the more conservative 'simple'
behavior, which only pushes the current branch to the corresponding
remote branch that 'git pull' uses to update the current branch.

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)

No refs in common and none specified; doing nothing.
Perhaps you should specify a branch such as 'master'.
fatal: The remote end hung up unexpectedly
error: failed to push some refs to 'c:/Users/gundlapa/GitRepoBare.git/'

This is where stuff breaks down. There error message on Windows isn’t clear enough. When you do a push, git tries to push the current branch (pointed by HEAD) to a branch of the same name in origin. So it is trying to push the clone’s ‘master’ branch to a ‘master’ branch in ‘origin’ remote. Do the following:

gundlapa@MARS-ROVER ~/GitRepoClone (master)
$ git push origin master:master
Counting objects: 3, done.
Writing objects: 100% (3/3), 211 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To c:/Users/gundlapa/GitRepoBare.git/
 * [new branch]      master -> master

gundlapa@MARS-ROVER ~/GitRepoClone (master)
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.

nothing to commit, working directory clean

gundlapa@MARS-ROVER ~/GitRepoClone (master)
$ cat>>temp.text
Hello

gundlapa@MARS-ROVER ~/GitRepoClone (master)
$ git commit -a -m test
[master a03bb36] test
 1 file changed, 1 insertion(+)

gundlapa@MARS-ROVER ~/GitRepoClone (master)
$ git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)

nothing to commit, working directory clean

gundlapa@MARS-ROVER ~/GitRepoClone (master)
$ 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

When push.default is set to 'matching', git will push local branches
to the remote branches that already exist with the same name.

In Git 2.0, Git will default to the more conservative 'simple'
behavior, which only pushes the current branch to the corresponding
remote branch that 'git pull' uses to update the current branch.

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.
Writing objects: 100% (3/3), 245 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To c:/Users/gundlapa/GitRepoBare.git/
   7fe023c..a03bb36  master -> master

gundlapa@MARS-ROVER ~/GitRepoClone (master)
$ git config --global push.default matching

gundlapa@MARS-ROVER ~/GitRepoClone (master)
$ git push
Everything up-to-date
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: