我正在尝试将一个分支添加到GitHub上的主分支,并将一个文件夹推送到该分支.
分支的文件夹结构如下 - SocialApp/SourceCode/DevTrunk/SocialApp,所有源代码文件都在最后一个文件夹中.
我使用以下Git命令:
git add *
git commit -m with the message
git push
Run Code Online (Sandbox Code Playgroud)
这只是将第一个文件夹"SocialApp"推送到GitHub并忽略文件夹内的文件夹SourceCode.我该如何解决?
小智 332
.gitignore
如果忽略子目录,请检查文件.
然后再试一次
git add --all
git commit -am "<commit message>"
git push
Run Code Online (Sandbox Code Playgroud)
小智 30
SETUP - 本地服务器上的本地存储库 - 客户端通过LAN连接到本地服务器
git add foldername/\\*
Run Code Online (Sandbox Code Playgroud)
把它带到服务器......
git commit -m "comments..."
git push remote_server_name master
Run Code Online (Sandbox Code Playgroud)
大多数情况下,用户将remote_server_name指定为origin ...
git remote add remote_server_name username@git_server_ip:/path/to/git_repo
Run Code Online (Sandbox Code Playgroud)
yka*_*kay 24
这对我有用:
git add . --force
Run Code Online (Sandbox Code Playgroud)
nop*_*oft 17
从顶级目录调用的"git add*"和"git add SocialApp"都应该递归地添加所有目录.
可能你在SocialApp/SourceCode/DevTrunk/SocialApp中没有文件,这就是原因.
尝试调用"touch SocialApp/SourceCode/DevTrunk/SocialApp/.temporary"(并检查.gitignore),然后再次尝试git add.
dis*_*rse 16
在我的例子中,子目录中有一个.git文件夹,因为我之前已经在那里初始化了一个git repo.当我添加子目录时,它只是将其添加为子项目而不添加任何包含的文件.
我通过从子目录中删除git存储库然后重新添加该文件夹来解决了这个问题.
场景/解决方案 1:
确保您的Folder
/Sub-folder
不在.gitignore
文件中,以防万一。
场景/解决方案 2:
默认情况下,以git add .
递归方式工作。
场景/解决方案 3:
git add --all :/
工作顺利,但git add .
工作不顺利。
(@JasonHartley 的评论)
场景/解决方案 4:
我个人面临的问题是添加Subfolders or Files
,这在多个Folders
.
例如:
Folder/Subfolder-L1/Subfolder-L2/...file12.txt
Folder/Subfolder-L1/Subfolder-L2/Subfolder-L3/...file123.txt
Folder/Subfolder-L1/...file1.txt
所以Git
建议我添加git submodule
,我尝试过但很痛苦。
最后对我有用的是:
1.git add
位于Folder
.
例如:
git add Folder/Subfolder-L1/Subfolder-L2/Subfolder-L3/...file123.txt
2.git add --all :/
现在。
它会非常迅速地添加所有Folders
,Subfolders
和files
。
小智 5
我遇到了这个问题,这花了我一些时间,然后想起git不会存储空文件夹。请记住,如果您有要存储的文件夹树,请将文件至少放置在该树的最深文件夹中,类似于名为“ .gitkeep”的文件,以通过git影响存储。
小智 5
如果要以递归方式添加目录及其中的所有文件,请转到要添加的目录所在的目录.
$ cd directory
$ git add directoryname
Run Code Online (Sandbox Code Playgroud)
导航到包含文件的文件夹,
如果您使用的是 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
Run Code Online (Sandbox Code Playgroud)
如果在将文件合并到主文件之前对文件进行任何更改,则必须通过执行来提交更改
git commit -m "applied some changes to the branch"
Run Code Online (Sandbox Code Playgroud)
在此之后签出分支到主分支
我只是用这个:
git add app/src/release/*
Run Code Online (Sandbox Code Playgroud)
您只需要指定要添加的文件夹,然后用于*
递归添加内部的所有内容。
我也有同样的问题,我没有 .gitignore 文件。我的问题是通过以下方式解决的。这需要所有子目录和文件。
git add <directory>/*
Run Code Online (Sandbox Code Playgroud)