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

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

我正在使用以下Git命令:

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

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


当前回答

导航到文件夹,你有你的文件,如果你是在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"

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

其他回答

从top directory调用“git add *”和“git add SocialApp”都应该递归添加所有目录。

可能你在SocialApp/SourceCode/DevTrunk/SocialApp中没有文件,这就是原因。

尝试调用touch SocialApp/SourceCode/DevTrunk/SocialApp/。临时的”(并检查。gitignore),然后再次尝试git add。

这对我很有效

git add -f *

这招对我很管用:

git add . --force

在我的例子中,子目录中有一个.git文件夹,因为我之前在那里初始化了一个git repo。当我添加子目录时,它只是将其作为子项目添加,而不添加任何包含的文件。

我通过从子目录中删除git存储库,然后重新添加文件夹来解决这个问题。

如果您想递归地添加一个目录和其中的所有文件,请转到要添加的目录所在的目录。

$ cd directory
$ git add directoryname