首页 > 解决方案 > git只推送2个文件

问题描述

我只更改了 2 个文件,它们是我唯一想推送到 Github 的文件。我已经添加了我想要的 2 个文件并提交了带有注释的更改。但是,当我推动时,我得到以下信息:

git push
To github.com:TinsleyBridgeGroup/TBL-bending-presses.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:TinsleyBridgeGroup/TBL-bending-presses.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

基于上述我 git 拉并收到以下错误:

git pull
error: Your local changes to the following files would be overwritten by merge:
        TBL165-238.json
        TBL165-279.json
Please commit your changes or stash them before you merge.
Aborting

如何推送我已更改“read_pressure.py”和“TBL165-238.json”的 2 个文件。一点背景知识,该脚本用于多个 IOT 设备。json 文件是特定于机器的设置,而 read_pressures.py 是通用的并在多台计算机上运行。下面列出了 Git 状态命令。

git status
On branch master
Your branch and 'origin/master' have diverged,
and have 1 and 3 different commits each, respectively.
  (use "git pull" to merge the remote branch into yours)
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:   .vscode/launch.json
        modified:   .vscode/settings.json
        modified:   TBL165-238.json
        modified:   TBL165-279.json
        modified:   read_pressure.py

no changes added to commit (use "git add" and/or "git commit -a")

标签: gitgithub

解决方案


请尝试以下步骤。

  1. 混帐藏匿
  2. git 拉
  3. git stash apply(如果有冲突,解决冲突)
  4. 混帐添加。
  5. git commit -m '消息'
  6. git 推送

推荐阅读