【发布时间】:2020-03-05 05:35:02
【问题描述】:
我在 Github 中创建了一个新的仓库,现在我只想推送 gitignore 文件。在下一次提交时,我想推送其余文件。
我做的步骤--
> git branch
* master
> git branch -r
> git status
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
new file: .idea/inspectionProfiles/Project_Default.xml
new file: .idea/vcs.xml
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: .gitignore
modified: .idea/workspace.xml
所以我把 .idea/workspace.xml 和 .idea 文件夹一起放在了 gitignore 中
> git add .gitignore
> git commit -m 'gitignore only'
我的问题是什么是推送命令,因为远程仓库中没有分支。
非常感谢任何帮助。
更新-1
我尝试了以下 -
git add .gitignore
git commit -m "git ignore only"
git push origin master
现在,当我检查远程 github 时,我可以看到所有文件都已添加。
【问题讨论】:
-
@Yousaf 不,我先创建了本地存储库,然后创建了远程存储库。现在我想第一次只提交 gitignore 文件。没有其他的。上次我尝试它提交了所有文件。
-
@CodeCaster 我没有推出任何新的分支。我想要的是将 gitignore 文件仅推送到远程。我认为这与您可能的重复链接没有任何关系。我刚刚添加了 gitignore 文件并提交,在 github 上我可以看到所有文件以及 .idea 文件夹。
-
那么你的 github 仓库有一个分支。
-
不..我刚刚展示了 git branch -r 结果。