From ba7cdf4b75f2bf6ead0f19c262d8870f9e7fd3a5 Mon Sep 17 00:00:00 2001 From: Neil Lathwood Date: Sat, 21 Jan 2017 11:48:35 +0000 Subject: [PATCH] docs: Added some hints and tips on using git (#5537) --- doc/Developing/Using-Git.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/doc/Developing/Using-Git.md b/doc/Developing/Using-Git.md index c4ceeb7be8..a0d21433a8 100644 --- a/doc/Developing/Using-Git.md +++ b/doc/Developing/Using-Git.md @@ -108,5 +108,26 @@ Thanks for your first pull request :) Ok, that should get you started on the contributing path. If you have any other questions then stop by our IRC Channel on Freenode ##librenms. +### Hints and tips + +Undo last commit + +`git reset --soft 'HEAD^'` + +Remove specific commit + +`git revert ` + +Restore deleted file + +`git checkout $(git rev-list -n 1 HEAD -- "$file")^ -- "$file"` + +Merge last two commits + +`git rebase --interactive HEAD~2` +In the text file that opens, change the last commit to squash from pick then save an exit. + +For more tips take a look at [Oh shit, git!](http://ohshitgit.com/) + [1]: http://gitready.com [2]: http://git-scm.com/book