![]() /././././ Change default message editor It can return the relative path to go back to project root: /home/workspace/myProject/test/phpunit/apps/sso/lib/action $ git rev-parse -show-cdup git path of the current project: $ git rev-parse -git-dir "git-rev-parse - Pick out and massage parameters"įor instance, this command can convert a commit ref to a real SHA1: $ git rev-parse HEAD~17 If you happen to be curious, feel free to explore the git rev-parse command: it’s a magic command used by many other commands to do many different things. home/workspace/myProject/test/phpunit/apps/sso/lib/action $ gr home/workspace/myProject $ cd test/phpunit/apps/sso/lib/action/ command.įor unix systems, this alias looks like this (put it in your ~/.bashrc file): /home/workspace/myProject $ alias gr= ' & cd `git rev-parse -show-cdup || pwd`' If your project has a deep directory tree, it can be useful to have a bash alias to go back to the root of the Git project in one line instead of multiple cd. My most used Git command is git status but instead of creating an alias like git st, I created a bash alias in my ~/.bashrc file: $ cat ~/.bashrcĪlias gst= "git status" Create a bash alias to go back to project root $ git config -global alias.rh "reset HEAD" To avoid adding the flag on every single diff command, you can make it a default option in your config: $ git config -global -bool diff.noprefix true Create your own aliasesĭo you know that you can create your own Git aliases ? $ git config -global "checkout" Thus, the prefix is quite useless so you can remove it in the diff output with the -no-prefix parameter: $ git diff -no-prefix This prefix can be a little bit annoying when you want to quickly copy and past the filename (for instance to paste it in a git add command). ![]() To stop viewing those ^M symbols, just change the whitespace option: $ git config -global core.whitespace cr-at-eol Remove file prefix in diffīy default, the git diff command displays the filename with either a/ or b/ prefix: $ git diff This is a problem when Windows and Unix developers work on the same Git project: Unix developers can see uglies ^M symbols at the end of lines created by Windows developers. Unix and Windows systems have different end-of-line characters. Ready? Improve diff output Avoid ^M in diff In this one, I will introduce you even more tricks to improve the diff output, create some useful aliases and master (no pun intended) mandatory commands to be able to approach advanced Git concepts and commands. Hey people! I hope you enjoyed the first part of the series. If you missed the first post, be sure to give it a read! And now fasten your belts folks, because this is some serious Git fu! This is the 2nd part of the Git Tips & Tricks series from Loïc Giraudel. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |