text Git很难:搞砸很容易,弄清楚如何解决你的错误是不可能的。所以这里有一些糟糕的情况我已经说过了

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了text Git很难:搞砸很容易,弄清楚如何解决你的错误是不可能的。所以这里有一些糟糕的情况我已经说过了相关的知识,希望对你有一定的参考价值。

## Oh shit, I did something terribly wrong, please tell me git has a magic time machine!?!

`git reflog`
### you will see a list of every thing you've done in git, across all branches! 
### Each one has an index HEAD@{index} find the one before you broke everything.

`git reset HEAD@{index}`
### magic time machine`

## Oh shit, I committed and immediately realized I need to make one small change!

### make your change
`git add . # or add individual files`
`git commit --amend`
### follow prompts to change or keep the commit message
### now your last commit contains that change!

## Oh shit, I need to change the message on my last commit!

`git commit --amend`
### follow prompts to change the commit message

## Oh shit, I accidentally committed something to master that should have been on a brand new branch!

### create a new branch from the current state of master
`git branch some-new-branch-name`
### remove the commit from the master branch
`git reset HEAD~ --hard`
`git checkout some-new-branch-name`
### your commit lives in this branch now :)

## Oh shit, I accidentally committed to the wrong branch!

### undo the last commit, but leave the changes available
`git reset HEAD~ --soft`
`git stash`
### move to the correct branch
`git checkout name-of-the-correct-branch`
`git stash pop`
`git add . # or add individual files`
`git commit -m "your message here"`
### now your changes are on the correct branch

## Cherry Pick 

`git checkout name-of-the-correct-branch`
### grab the last commit to master
`git cherry-pick master`
### delete it from master
`git checkout master`
`git reset HEAD~ --hard`

## Oh shit, I tried to run a diff but nothing happened?!

`git diff --staged`
### Git won't do a diff of files that have been add-ed to your staging area without this flag. 

## Fuck this noise, I give up.

`cd ..`
`sudo rm -r fucking-git-repo-dir`
`git clone https://some.github.url/fucking-git-repo-dir.git`
`cd fucking-git-repo-dir`

以上是关于text Git很难:搞砸很容易,弄清楚如何解决你的错误是不可能的。所以这里有一些糟糕的情况我已经说过了的主要内容,如果未能解决你的问题,请参考以下文章

我无法弄清楚具有三种状态(启动、停止和重置)的 UIButton

行为驱动开发(BDD) - 深入了解

DBUnit 中的日志输出

除了关闭 Bitcode 之外,您如何弄清楚如何优化 IPA 编译大小?

无法弄清楚有效载荷是如何工作的

使用 OpenGL ES 2.0 绘制 2D 图像