【发布时间】:2015-10-18 13:34:17
【问题描述】:
我需要将我的所有提交放在一个称为初始快照的单个快照中,以便在 github 存储库中发布它,我知道为此我遵循 this
我的第一个问题是我想与外部存储库共享它,这说:
请注意:仅对尚未推送的提交执行此操作 外部存储库。如果其他人基于提交的工作 你要删除,可能会发生很多冲突。只是不要 如果您的历史已与他人共享,请改写它。
我想把我所有的提交放在一个单一的,怎么做:
我也发现了这个:
# Switch to the master branch and make sure you are up to date.
git checkout master
git fetch # this may be necessary (depending on your git config) to receive updates on origin/master
git pull
# Merge the feature branch into the master branch.
git merge feature_branch
# Reset the master branch to origin's state.
git reset origin/master
# Git now considers all changes as unstaged changes.
# We can add these changes as one commit.
# Adding . will also add untracked files.
git add --all
git commit
但什么也没发生:
$ git reset origin/master
$ git add --all
$ git commit -m "initial snapshot"
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
【问题讨论】:
-
你从
git rev-parse master origin/master得到什么?似乎在运行git reset之前,您可能已经放弃了您的工作。如果您有,请不要担心,因为您可以在 reflog (git log -g) 中找到它。 -
这是我得到的:$ git rev-parse master origin/master 78c4e31d7f813a127603aa93d63eb2c9db8d7c47 78c4e31d7f813a127603aa93d63eb2c9db8d7c47
-
好的,所以 master 回到了 origin/master。
git diff或git diff --cached HEAD是否显示您的树或索引中的任何更改?如果没有,您可能需要通过git log -g找到您丢失的主人的内容。 -
自 2016 年 3 月以来,您不再需要压缩提交:请参阅 stackoverflow.com/a/36377634/6309