【问题标题】:pushed and committed to github but apparently only some of the changes推送并提交到 github 但显然只有一些更改
【发布时间】:2015-10-06 03:45:45
【问题描述】:

我已提交并将更改推送到 github.com,但是当我删除本地目录并将 repo 克隆到本地计算机时,我得到一组文件,这些文件反映了上次提交中添加的新文件和缺失在最后一次提交中删除的文件。我得到的是上次提交中修改的文件,也就是说,我收到了这些文件,但它们是旧版本。

我还需要执行哪些其他步骤?

在此之后,我对自述文件进行了小幅编辑,我注意到有一条消息“您的分支比 'origin/master' 领先 1 次提交”。这是什么意思以及如何修复它?

user@pcLinux:~/backup9$ git commit
On branch master
Your branch is up-to-date with 'origin/master'.

Changes not staged for commit:
    modified:   README.md

no changes added to commit
user@pcLinux:~/backup9$ git add README.md
user@pcLinux:~/backup9$ git commit
[master b4c856a] Improve the formatting of README.md.
 1 file changed, 22 insertions(+), 5 deletions(-)
user@pcLinux:~/backup9$ git push https://github.com/H2ONaCl/backup9.git master
Username for 'https://github.com': H2ONaCl
Password for 'https://H2ONaCl@github.com': 
Counting objects: 5, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 509 bytes | 0 bytes/s, done.
Total 3 (delta 2), reused 0 (delta 0)
To https://github.com/H2ONaCl/backup9.git
   f082024..b4c856a  master -> master
user@pcLinux:~/backup9$ git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)

nothing to commit, working directory clean

编辑:我删除了目录并再次克隆。貌似是从github收到了README.md的修改,但是对其他文件的修改没有,也就是说其他文件还是老版本。

【问题讨论】:

    标签: github


    【解决方案1】:

    在您的序列中,您只需添加并提交 README.md,因此新的克隆将反映该修改。

    如果您想确保包含所有修改/添加/删除:

    git add -A .
    git commit -m "new commit"
    git push
    

    【讨论】:

    • 是的,但在前面未显示的序列中,我添加了文件、删除了文件和修改了文件。添加和删​​除在重新克隆时可用,但在修改时不可用。
    • @H2ONaCl 当然:下次试试git add -A .,看看效果是否更好。使用git check-ignore -v -- myfile 也检查那些文件是否被忽略。
    • 可能我在想 mercurial add,它“早期”用于未知文件,因为 git add 明显不同。
    • @H2ONaCl 关于 git 'add' 之一,您可以在stackoverflow.com/a/3003322/6309stackoverflow.com/a/16162511/6309stackoverflow.com/a/24950133/6309 看到更多信息
    • @H2ONaCl 顺便说一句,您也可以使用:git commit -m 'your message' . && git push :-)
    猜你喜欢
    • 1970-01-01
    • 2015-04-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-01
    • 2015-10-25
    相关资源
    最近更新 更多