git - Trying to set up remote repo and push to it, getting confused -


i have local repo set on laptop's hard drive, @ c:\somefolder\.git. want set remote repo on windows server @ x:\someotherfolder backup. here steps have taken far:

  1. in x:\someotherfolder, opened git bash session , entered git clone "c:\somefolder". got message cloning 'somefolder'...done.

  2. in c:\somefolder, opened git bash session , entered git remote add origin "x:\someotherfolder". statement executed without response.

  3. made changes in local project files , committed them local repo git commit -am.

  4. from c:\somefolder git bash, entered git push origin master. response is:

--

remote: error: refusing update checked out branch: refs/heads/master  remote: error: default, updating current branch in non-bare repository remote: error: denied, because make index , work tree inconsistent remote: error: pushed, , require 'git reset --hard' match remote: error: work tree head. 

etc.

i feel set remote incorrectly. should instead?

remote server can bare repository (repository without content).
in order have such repository need create --bare flag

# create (bare) remote repository git init --bare 

now should see content of .git folder file system of repository , can start using it.


why should remote repository bare repository?

remote repository not have working directory. contains content pushed other local repositories.


to user did down vote , commented out don't need bare repository: don't need convention.

read in here: https://git-scm.com/book/en/v2/git-on-the-server-getting-git-on-a-server

in order set git server, have export existing repository new bare repository – a repository doesn’t contain working directory.

this straightforward do.
in order clone repository create new bare repository, run clone command --bare option.


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -