DEV Community

Daily git usage

Pavel Movchan on October 29, 2017

Hi guys! We all use Git every day typing commands such as git push origin master many times a day. But maybe you have aliases contracting to git p....
Collapse
 
bgadrian profile image
Adrian B.G.

You are using the force flag everyday, OMG I hope we will not be co-workers ...anytime ๐Ÿ˜

Collapse
 
x0st profile image
Pavel Movchan • Edited

I use the rebase feature every day many times because do not like mess in my git repositories. Of course when I work with other people i don't use the force flag.

Collapse
 
nutondev profile image
nuton.dev

It depends on the circumstances. If he is developing a branch alone and needs to correct his PR and push again for review, what would you do?

Collapse
 
bgadrian profile image
Adrian B.G.

If you want to remove the history you don't have much of a choice, it was a joke.

I would use git merge squash and instead of --force flag I would use --force-with-lease to avoid possible data loss.

Collapse
 
cchileshe profile image
Christopher Chileshe

I applaud this. I think it's great when developers leverage each other's existing tools to simplify common tasks. To me it seems like this tool abstracts the complexities of git commands, why not just use a tool like SourceTree or GitKraken? They are visual tools that do a lot of heavy lifting for you and have imo made my life so much easier. BTW I don't work for either of those nor do I get any kind of compensation from them, but I think they are worthwhile tools if the goal is to make life easier

Collapse
 
x0st profile image
Pavel Movchan

I agree with you about the tools but i use vim a lot and prefer using command line. That's people choice what to use :)

Collapse
 
joshcheek profile image
Josh Cheek

Nice!

Careful with that force flag, though! (I use the that flag less than once a month, but reading your other comments, I also barely ever rebase).

Note that when I use git commit --amend, I use -CHEAD about 90% of the time.

What are the --smart flags? Is that a new feature? I'm on git 2.15.1 and don't see it in the man page, or when I try using them just to see if they work.

For git log --pretty, I spent a day reading the man page, and wound up with a helper, which is aliased to git log --pretty=format:'%Cgreen%h%Creset %Cblue%ad%Creset %s%C(yellow)%d%Creset %Cblue[%an]%Creset' --graph --date=short, it tends to be as terse as git log --format=oneline, but also includes the useful author and branch info of git log --pretty.

Collapse
 
x0st profile image
Pavel Movchan

The smart flags are not built in Git. That's just my 'aliases' for the commands.

Collapse
 
shriharshmishra profile image
Shriharsh

I also have a similar pattern of command repetition. I will try your script. Thanks!!

Collapse
 
x0st profile image
Pavel Movchan

If you need any additional commands, please let me know! I'll try to make your life easier :)

Collapse
 
shriharshmishra profile image
Shriharsh

Sure.. Thanks!

Collapse
 
seankilleen profile image
Sean Killeen

Hey! I've noticed that in this post you use "guys" as a reference to the entire community, which is not made up of only guys but a variety of community members.

I'm running an experiment and hope you'll participate. Would you consider changing "guys" to a more inclusive term? If you're open to that, please let me know when you've changed it and I'll delete this comment.

For more information and some alternate suggestions, see dev.to/seankilleen/a-quick-experim....

Thanks for considering!

Collapse
 
netanelravid profile image
Netanel Ravid

First of all thanks for your sharing
Second, if you are using z shell (zsh, if you are not using it, leaving everything and read about it now, it's amazing!) you can use the git plugin which is super cool
gcam - git commit -a -m
gp - git push
gl - git pull
gb - git branch
gst - git status
It saves me minutes (even hours) a day just using those aliases.

Collapse
 
x0st profile image
Pavel Movchan

I do use zsh :)

Collapse
 
pekhota profile image
Alexander Pekhota

Good job!

Collapse
 
heyay profile image
Ayush

Can you please make a whole cheatsheet with all commands in pdf format?

Collapse
 
gyandeeps profile image
Gyandeep Singh

Nice, thanks for sharing.
I have also created couple of bash helpers to streamline my git workflow: gyandeeps.com/git-helpers/

Collapse
 
ghost profile image
Ghost

Love your script! Thank you so much for sharing ๐Ÿ˜Š

Collapse
 
x0st profile image
Pavel Movchan

Thank you! Make sure to have the most new version :)

Collapse
 
gmaiolo profile image
Guillermo Maiolo

Force command is always one key away and right next to the normal command, I wouldn't recommend that at all.

Collapse
 
x0st profile image
Pavel Movchan

Speacially for you I've added confirmation when using the force commands (:

Collapse
 
emgodev profile image
Michael

Nice! I have been using bash aliases, I hope to learn scripting more.