我正在处理一个文件x,并添加了一些新的代码行,我还不想提交。这意味着我想看一些先前的提交,我可以通过git checkout bla
来完成。但是,我该如何回到未提交的原始x
答案 0 :(得分:2)
假设您在master
分支上(但它适用于您所在的任何分支):
git stash
git checkout 0c80e02
git checkout master
git stash pop
如果您尝试不使用stash
,则会收到一条消息,指出您的本地更改将被checkout
覆盖。
有关详细信息,请参阅文档:https://git-scm.com/book/en/v1/Git-Tools-Stashing
答案 1 :(得分:1)
您可以使用git stash隐藏更改,然后转到需要的提交
Put: Table empty. Inflating table to threshold:16
Inflate: RoundUpPowerOf2 of size=16
Inflate: Setting Min of [capacity * loadFactor, MAXIMUM_CAPACITY + 1] as threshold
Inflate: Given values[capacity=16, loadfactor=0.75, MAXIMUM_CAPACITY=1073741824
Creating array of Entry[] with size:16
Put: Key not null:0
IndexFor: calculating index for [given hash=0, length=16]
Put: Obtained index:0
Put: Incrementing modCounter
Put: Adding a new Entry[hash=0, key=0, value=Z, i=0]
Put: Key not null:1
IndexFor: calculating index for [given hash=1, length=16]
Put: Obtained index:1
Put: Incrementing modCounter
Put: Adding a new Entry[hash=1, key=1, value=A, i=1]
Put: Key not null:16
IndexFor: calculating index for [given hash=16, length=16]
Put: Obtained index:0
Put: Iteraing over table[0] elements
Put: Incrementing modCounter
Put: Adding a new Entry[hash=16, key=17, value=A, i=0]
然后您可以返回最新提交并解除支持
ko.subscribable.fn.subscribeChanged = function (callback) {
var oldValue;
this.subscribe(function (_oldValue) {
oldValue = _oldValue;
}, this, 'beforeChange');
this.subscribe(function (newValue) {
callback(newValue, oldValue);
});
};