git - 在 github 中创建新仓库后第一次提交 gitignore
问题描述
我在 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
gitignore 和.idea
文件夹一起放进去
> git add .gitignore
> git commit -m 'gitignore only'
我的问题是什么是推送命令,因为远程仓库中没有分支。
非常感谢任何帮助。
更新-1
我尝试了以下 -
git add .gitignore
git commit -m "git ignore only"
git push origin master
现在,当我检查远程 github 时,我可以看到所有文件都已添加。
解决方案
这两个文件已经处于“暂存”状态Project_Default.xml
。vcs.xml
添加它们.gitignore
不会影响在 nextgit commit
中它们将被集成到提交中的事实(因为它们是“分阶段的”)。
正如我们在gitignore 文档中看到的那样:“Git 已跟踪的文件不受影响”
推荐阅读
- vaadin - 如何以原生方式从 Vaadin 后端向一个或特定数量的(Android 智能手机)用户发送通知?
- html - 更改 Instagram 嵌入的显示文本?
- reactjs - React:通过 HOC 注入 props 而不为它们声明类型
- java - Firebase 中 Firestore 数据库中的计数器
- django - 在 Wagtail 中实现这一最终目标的最佳方法是什么?
- github-actions - `on` 语法生成动作的重复运行
- javascript - 为什么 linter 会选择无用的转义字符?
- python - 在保持全局特征的 NetworkX 上采样
- r - 矩阵形式的标准化到非标准化之间的转换
- regex - Oracle PLSQL regexp_substr 用双引号分隔逗号分隔的字符串