Skip to content

Instantly share code, notes, and snippets.

View clementprem's full-sized avatar

Clement Prem clementprem

View GitHub Profile
## Clean Local Branch
git branch -d $(git branch --merged |tail -n +2)
@clementprem
clementprem / revert-a-commit.md
Last active December 7, 2018 17:27 — forked from gunjanpatel/revert-a-commit.md
Git HowTo: revert a commit already pushed to a remote repository

Revert the full commit

Sometimes you may want to undo a whole commit with all changes. Instead of going through all the changes manually, you can simply tell git to revert a commit, which does not even have to be the last one. Reverting a commit means to create a new commit that undoes all changes that were made in the bad commit. Just like above, the bad commit remains there, but it no longer affects the the current master and any future commits on top of it.

git revert {commit_id}'

About History Rewriting

Delete the last commit

Deleting the last commit is the easiest case. Let's say we have a remote origin with branch master that currently points to commit dd61ab32. We want to remove the top commit. Translated to git terminology, we want to force the master branch of the origin remote repository to the parent of dd61ab32:

@clementprem
clementprem / .gitattributes
Last active December 7, 2018 12:18 — forked from asmallteapot/.gitattributes
Diff Xcode localizable strings files in Git.
*.strings utf16 diff=localizablestrings
/// Every view interacting with a `SayHelloViewModel` instance can conform to this.
protocol SayHelloViewModelBindable {
var disposeBag: DisposeBag? { get }
func bind(to viewModel: SayHelloViewModel)
}
/// TableViewCells
final class TextFieldCell: UITableViewCell, SayHelloViewModelBindable {
@IBOutlet weak var nameTextField: UITextField!
var disposeBag: DisposeBag?