我已经rebase过, 但是我不想强推(force push) 不幸的是,如果你想把这些变化(changes)反应到远程分支上,你就必须得强推(force push)。是因你快进(Fast forward)了提交,改变了Git历史, 远程分支不会接受变化(changes),除非强推(force push)。这就是许多人使用 merge 工作流, 而不是 rebasing 工作流的主要原因之...
git stashallows us to save the changes but does not require agit commit; it acts as temporary storage for uncommitted files. After adding changes to temporary storage, we’ll tell Git todropthose are stored. Hence, all uncommitted changes will be gone. ...
$ git stash pop 或者, stash 你不需要的部分, 然后stash drop。 代码语言:javascript 代码运行次数:0 复制 Cloud Studio代码运行 $ git stash-p # Select allofthe snippets you don't want to save $ git stash drop 分支(Branches) 我从错误的分支拉取了内容,或把内容拉取到了错误的分支 这是另外一种...
$ git checkout-p# Answer y to all of the snippets you want to drop 另外一个方法是使用 stash, Stash所有要保留下的内容, 重置工作拷贝, 重新应用保留的部分。 $ git stash-p# Select all of the snippets you want to save$ git reset--hard $ git stash pop ...
$ git checkout -p # Answer y to all of the snippets you want to drop1.2. 另外一个方法是使用 stash, Stash所有要保留下的内容, 重置工作拷贝, 重新应用保留的部分。 复制 $ git stash -p # Select all of the snippets you want to save $ git reset --hard $ git stash pop1.2.3.4. ...
这只能在没有推送之前有用. 如果你已经推了, 唯一安全能做的是 git revert SHAofBadCommit, 那会创建一个新的提交(commit)用于撤消前一个提交的所有变化(changes);或者, 如果你推的这个分支是rebase-safe的 (例如:其它开发者不会从这个分支拉), 只需要使用 git push -f。
To remove uncommitted changes in Git, the “$ git rm filename” command, “$ git reset --hard HEAD” command, or “$ git stash drop” can be utilized.
$ git stash drop 1. 2. 3. 分支(Branches) 我从错误的分支拉取了内容,或把内容拉取到了错误的分支 这是另外一种使用 git reflog 情况,找到在这次错误拉(pull) 之前HEAD的指向。 (main)$ git reflog ab7555f HEAD@{0}: pull origin wrong-branch: Fast-forward ...
我想丢弃本地未提交的变化(uncommitted changes) 如果你只是想重置源(origin)和你本地(local)之间的一些提交(commit),你可以: # one commit(my-branch)$ git reset--hardHEAD^# two commits(my-branch)$ git reset--hardHEAD^^# four commits(my-branch)$ git reset--hardHEAD~4# or(main)$ git check...
我想丢弃本地未提交的变化(uncommitted changes) 如果你只是想重置源(origin)和你本地(local)之间的一些提交(commit),你可以: 代码语言:javascript 复制 ## one commit (my-branch)$ git reset --hard HEAD^ ## two commits (my-branch)$ git reset --hard HEAD^^ ## four commits (my-branch)$ git ...