search

Home  >  Q&A  >  body text

When using git clone to project on github, the project folder is duplicated. How to solve it?

There is a workspace folder, which contains four folders a, b, c, and d

Suppose there is a project named c on my github

I git init directly in the c folder under the workspace, and then git clone the c project on github
This creates another c folder, which is very troublesome

If you git init directly in the workspace, there will be only one c folder.
But I am afraid to push the files a, b, and d to github later. .
Is there such a good way?
Does everyone create a warehouse directly under the workspace, and then write gitignore rules to filter a, b, d?

给我你的怀抱给我你的怀抱2772 days ago917

reply all(6)I'll reply

  • 世界只因有你

    世界只因有你2017-05-02 09:48:51

    git clone --help
    git clone [--template=<template_directory>]
                     [-l] [-s] [--no-hardlinks] [-q] [-n] [--bare] [--mirror]
                     [-o <name>] [-b <name>] [-u <upload-pack>] [--reference <repository>]
                     [--dissociate] [--separate-git-dir <git dir>]
                     [--depth <depth>] [--[no-]single-branch]
                     [--recursive | --recurse-submodules] [--] <repository>
                     [<directory>]

    You can see that the last parameter is the directory name.

    reply
    0
  • 阿神

    阿神2017-05-02 09:48:51

    Don’t understand what you mean?

    I directly git clone the corresponding project address to the workspace. Is there any problem with this? I don’t quite understand?

    reply
    0
  • 漂亮男人

    漂亮男人2017-05-02 09:48:51

    Look carefully at lz’s description, there is a folder dir under the workspace.

    git clone http://*.github.com/demo.git dir

    Can you try this?

    The mac file system is not case-sensitive.

    There are two folders dir and dir in the repositroy.
    github will display two folders, and when you clone it, only dir may be displayed.

    Then you can do it locally

    mv dir dr

    Then the files in the two local folders were moved and the dr file was downloaded.

    reply
    0
  • 世界只因有你

    世界只因有你2017-05-02 09:48:51

    If you don’t want to put other filespush上去,就用.gitignore过滤掉。你说的直接在c文件夹下git init会多出来c文件,你可以直接服务器上的c文件夹内容pull into the local c folder, wouldn’t it be fine

    reply
    0
  • 滿天的星座

    滿天的星座2017-05-02 09:48:51

    Use the command in the c folder under the workspace folder

    cd existing_folder
    git init
    git remote add origin git@github.example.com:yourRepository/yourRepository.git
    git add .
    git commit
    git push -u origin master

    In this way, your local c folder will be synchronized to the remote github repository

    reply
    0
  • 仅有的幸福

    仅有的幸福2017-05-02 09:48:51

    If there is already a remote library and there are few new contents in the c project folder in the workspace, please do the following:

    1. Delete the cproject folder

    2. in the workspace folder
    3. Clone from the remote repository: git clone http://your.github.com/c.git c
      After the command is executed, the remote repository will be copied to the local directory, which means that the c folder at this time is already the local repository and has nothing to do with the a, b, d folders.

    All git can be executed in the gitc folder.

    Reference tutorial: Liao Xuefeng’s git tutorial-remote warehouse

    reply
    0
  • Cancelreply