• 请不要在回答技术问题时复制粘贴 AI 生成的内容
ylcx123
V2EX  ›  程序员

git 能设置本机某个位置为远程仓库吗?

  •  
  •   ylcx123 · Sep 15, 2015 · 4950 views
    This topic created in 4093 days ago, the information mentioned may be changed or developed.
    1. 项目是用 SVN 管理的,但是我为了使用本地临时提交,用了 git 来管理本地提交。
    2. 我有个坏习惯,遇到项目出问题时(非代码问题),我会删除项目文件夹,重新从 SVN checkout 出来。这也就导致项目文件夹里的.git 文件夹被删除了。
    3. 这事发生过两次。所以想有没有 git 本地远程仓库?就是把某个其他位置的文件夹设为远程仓库?
    14 replies  •  2015-09-15 11:29:50 +08:00
    dorentus
    dorentus
    Sep 15, 2015 via iPhone
    1
    可以 关键字 bare repo

    另外,最好改掉这个习惯
    FrankFang128
    FrankFang128
    Sep 15, 2015 via Android
    2
    顶一楼,改习惯就好了
    ShadowStar
    ShadowStar
    Sep 15, 2015 via iPad
    3
    file:///Path/to/gitrepo
    或者有个脚本 git-new-workdir ,大概这个名字。
    msg7086
    msg7086
    Sep 15, 2015❤️1
    4
    1. 可以,直接指定就好了。是不是 bare 无所谓。就算是 working directory 也可以再次 clone 的。
    2. 改掉这个坏习惯。
    cxbig
    cxbig
    Sep 15, 2015
    5
    可以,本地文件夹 A 克隆远程 repo ,本地文件夹 B 克隆本地文件夹 A ,用 B 文件夹做工作目录
    如楼上所说,坏习惯要改。 git checkout -f 足够清理干净了。
    582033
    582033
    Sep 15, 2015 via Android
    6
    出问题个人做法是切一个新分支,然后后退几个版本重新 rebase.
    letterJump
    letterJump
    Sep 15, 2015
    7
    本地直接同步目录备份就可以了
    chinawrj
    chinawrj
    Sep 15, 2015
    8
    git init --bare 好啦
    ljbha007
    ljbha007
    Sep 15, 2015
    9
    git init --bare

    然后到别处
    git clone /path/to/my/git

    提交的时候 git add -A&git commit

    git push
    ljbha007
    ljbha007
    Sep 15, 2015
    10
    还有 想回退 直接 git reset --hard . 就行了
    sudoz
    sudoz
    Sep 15, 2015
    11
    git init --bare <repo-name>
    ylcx123
    ylcx123
    OP
    Sep 15, 2015
    12
    非简单问题,比如之前遇到过的, SVN 的 cleanup 死循环了,最后下了个 sqlite3 才解决。
    还有 eclipse 项目感叹号等, git reset 都不行。

    估计与 SVN 和 git 混用有关

    PS:SVN 排除了.git 文件夹,但是 git 添加了.svn 文件夹。
    ylcx123
    ylcx123
    OP
    Sep 15, 2015
    13
    @ljbha007
    如果远程仓库是本机的“ E:\\Git\myproject.git\”呢?
    本地项目在“ D:\\SVN\myproject\”
    如何写: git remote -add orgin E:\\Git\myproject.git 这样吗?
    push 的时候报错:

    $ git push --set-upstream origin master
    fatal: 'E:Gitmyproject.git' does not appear to be a git repository
    fatal: Could not read from remote repository.

    Please make sure you have the correct access rights
    and the repository exists.
    ylcx123
    ylcx123
    OP
    Sep 15, 2015
    14
    @ylcx123
    原来是这样写: git remote add origin file:///E://abc//myproj.git
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1987 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 57ms · UTC 12:10 · PVG 20:10 · LAX 04:10 · JFK 07:10
    ♥ Do have faith in what you're doing.