DEV Community

Advanced git tips

Aravind Balla on September 23, 2018

Git is amazing and you will learn only by using it. Try to learn the commands, you will forget if you don't use them. The same is the case for GUIs...
Collapse
 
5422m4n profile image
Sven Kanoldt

that you can use virtual hostnames and map them in the .ssh/config to real ones was new, thanks for sharing!

one more git alias that I find very handy, to set a local branch up with the origin counterpart branch:

[alias]
    track = "!git branch --set-upstream-to=origin/`git symbolic-ref --short HEAD`"
Collapse
 
codicacom profile image
Codica

Thanks for sharing the tips, Aravind! They are very helpful.

Everyone has their favourite Git commands. Our dev team has prepared a list of top lifesaving commands that help us in many situations, some of them may add up to to your list: codica.com/blog/useful-git-command...

We would love to hear what you think of them :)

Collapse
 
aravindballa profile image
Aravind Balla

Cool! I didn't know git branch --merged but felt the need most of the times.

Collapse
 
chancethehacker profile image
Chance The Hacker

Thanks, I wasn't aware of any of these tips!

Collapse
 
xexyl profile image
xexzy

Re 'Learn what you need. Google what you don't. Try remembering if you are googling the same thing often.'

Just want to point out that masters of memory will refute that. You should just learn to memorise things. It can be done. Of course it might be easier for some to be lazy and that's something that most people indeed are; but if nothing else you could keep your own document in the way you learn or say a cheatsheet. But by memorising things you will make it easier in the long run. Anyway keeping a cheatsheet is not the most efficient way of learning but I guess it works for most people.

Collapse
 
xexyl profile image
xexzy

Re 'There will a ~/.gitconfig file where you can specify them. (If you don't find the file, I think you can create it at HOME path).'

Unless Iā€™m parsing what you're saying wrong: $HOME will be the same value as ~ (except that with ~ you can do ~luser and it'll translate to the $HOME variable of the user luser). Or are you saying something else?

But it should also be pointed out that that's a global config file; you can also have it per repo i.e. at .git/config