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?
世界只因有你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.
阿神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?
漂亮男人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
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.
mv dir dr
Then the files in the two local folders were moved and the dr file was downloaded.
世界只因有你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
滿天的星座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
仅有的幸福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:
Delete the c
project folder
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 git
在c
folder.
Reference tutorial: Liao Xuefeng’s git tutorial-remote warehouse