有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java从现有项目创建新的本地回购

我有一个新的java项目,第一次想把它推到我电脑上的本地存储库(不是github或remote)
我使用了这些命令
1:git init
2:git-add
3:git提交
4:git推送

我成功地推送了它,但我只想知道这个存储库地址(路径)是什么,要克隆还是放在其他地方
谢谢


共 (2) 个答案

  1. # 1 楼答案

    Git的基本操作建立在远程仓库、本地仓库、临时存储区和工作区。你的行为如上所述

    1. git initgit init命令初始化本地仓库
    2. git add .将当前工作区中的文件临时存储到临时存储区域
    3. git commitgit commit将临时区域数据提交到本地仓库
    4. git pushgit push将本地仓库数据提交到远程仓库

    下面是一幅非常直观的图片

    Command flow diagram

    如图所示,您只能将本地仓库数据拉入并合并到本地工作区中

    根据需要,您只能在本地构建git服务器,并且可以通过局域网中的ip地址访问本地构建的服务

  2. # 2 楼答案

    want to push it on local repository on my pc(Not github or remote)for first time.

    然后,您需要创建一个空的bare存储库(意思是没有任何签出文件的Git repo),它将用作远程推送:

    cd C:\repos
    git init  bare my_new_repo.git
    
    cd C:\path\to\existing\Git\repository
    git remote add origin file://C/repos/my_new_repo.git
    git push -u origin main
    

    what is this repository address(path) to clone or put it in other place?

    它使用的是local file protocol,因此其URL为:

    file://C/repos/my_new_repo.git