Posts

Git: Rollback an old commit

Try:  git checkout . (Don't forget . ) Undo: git reset --hard https://stackoverflow.com/questions/2007662/rollback-to-an-old-git-commit-in-a-public-repo

Git: Delete a commit in a remote branch

For latest commit: git reset --hard HEAD~1 / git reset --hard git push origin HEAD --force https://stackoverflow.com/questions/1338728/delete-commits-from-a-branch-in-git For old commits: git rebase -i Change pick to drop for commits which you want to delete. Maybe resolve conflict and continue rebase Change a new message commit git push --force

Git squash

P -> Q -> R \ .--> X -> Y P -> Q -> R \ .--> Z git rebase -i Change pick to squash for some commits which want to squash. Save and quit. Change a new message commit for squashing. Save and quit. git push --force https://github.com/servo/servo/wiki/Beginner's-guide-to-rebasing-and-squashing

Git: Changing a commit message

For the latest commit: git commit --amend I n text editor, edit the commit message, and save the commit. git push --force https://help.github.com/en/articles/changing-a-commit-message For old commits: git rebase -i ( previous commit which you want to change message) On top of text edtior, change pick to reword Change a new message commit git push --force https://stackoverflow.com/questions/1884474/change-old-commit-message-on-git

How to sync an iPhone with Mac without deleting everything

Follow these steps to manually manage music and videos on your iPhone: Connect the iPhone to your first computer. Open  iTunes . Select the iPhone using the Device menu in the top-left. Click the Summary option and select Manually Manage Music and Videos . Click Apply. You can manually drag and drop the music files, and videos that you want between your Mac and your iPhone.

Git: Thay Đổi Commit Cuối Cùng (commit amend)

Nếu như bạn thực hiện xong commit và rồi sau đó mới nhận ra rằng đã quên tổ chức các thay đổi trong tập tin bạn muốn để thêm vào commit đó, bạn có thể chạy lệnh sau: $ git add forgotten_file $ git commit --amend $ git push --force

Delete the second last commit

Delete the second last commit Let's say the bad commit  dd61ab32  is not the top commit, but a slightly older one, e.g. the second last one. We want to remove it, but keep all commits that followed it. In other words, we want to rewrite the history and force the result back to  mathnet/master . The easiest way to rewrite history is to do an interactive rebase down to the parent of the offending commit: 1: $ git rebase -i dd61ab32^ This will open an editor and show a list of all commits since the commit we want to get rid of: 1: 2: 3: pick dd61ab32 pick dsadhj278 .. . Simply remove the line with the offending commit, likely that will be the first line (vi: delete current line =  dd ). Save and close the editor (vi: press  :wq  and return). Resolve any conflicts if there are any, and your local branch should be fixed. Force it to the remote and you're done: 1: $ git push mathnet -f