我试图在GitHub上添加一个分支到主分支,并将一个文件夹推到该分支上。

分支的文件夹结构看起来像- SocialApp/SourceCode/DevTrunk/SocialApp和所有源代码文件都在最后一个文件夹中。

我正在使用以下Git命令:

git add *
git commit -m with the message
git push

这只是将第一个文件夹“SocialApp”推到GitHub上,而忽略了文件夹内的文件夹SourceCode。我怎么解决这个问题?


当前回答

我遇到了这个问题,花费了我一点时间,然后我想起git不会存储空文件夹。请记住,如果您有一个想要存储的文件夹树,请至少将一个文件放在该树最深的文件夹中,例如一个名为“”的文件。Gitkeep”,只是为了影响git的存储。

其他回答

设置

本地服务器上的本地存储库 客户端通过局域网连接到本地服务器

更新(2020年9月):使用文件夹名/\*代替文件夹名/\\*:

git add foldername/\*

为了到达服务器…

git commit -m "comments..."
git push remote_server_name master

大多数情况下,用户会将remote_server_name指定为origin…

git remote add remote_server_name username@git_server_ip:/path/to/git_repo

如果子目录被忽略,检查.gitignore文件。

然后再试一次

git add --all
git commit -am "<commit message>"
git push

这对我很有效

git add -f *

导航到文件夹,你有你的文件,如果你是在windows机器上,你将需要启动git bash,从中你将得到一个命令行界面,然后使用这些命令

git init   //this initializes a .git  repository in your working directory

git remote add origin <URL_TO_YOUR_REPO.git> // this points to correct repository where files will be uploaded

git add *   // this adds all the files to the initialialized git repository

如果您在将文件合并到主文件之前对其进行了任何更改,则必须通过执行提交更改

git commit -m "applied some changes to the branch"

在这之后,将分支签出到主分支

有时,我希望将我的web服务源代码与其客户端项目一起包含。它们都有独立的git存储库。 我实际上习惯于使用命令添加所有文件:

git add -A

但出于某种原因,它只添加了文件夹。后来我发现服务器文件中也有它的.git文件夹,所以这个命令不起作用。

tl;dr:确保在要运行的文件夹中没有.git文件夹。