DEV Community

Cover image for Which git commands do you struggle with?
Ben Halpern
Ben Halpern

Posted on

Which git commands do you struggle with?

Which git commands and concepts do you have a hard time wrapping your head around and using regularly?

And with the commands you struggle with: Do you use them despite your difficulties or do you generally avoid them?

Source of the cover image. πŸ˜„

Latest comments (46)

Collapse
 
csgeek profile image
csgeek

git-filter-branch is very cool to re-write entire history and reflog which lets you undo certain "oops" moments.

I wish I understood both of them better.

Collapse
 
bizzibody profile image
Ian bradbury

All of them.

Collapse
 
polterguy profile image
Thomas Hansen • Edited

Jeff Bezos has a rule; "Two pizza should be sufficient to comfortably feed a software development team". So what on earth does this has to do with git you may ask?

Well, if your git branches ends up looking like a x-mas tree, or guitar hero (LOL!), this is a symptom of complexity, often originating from the size of your team, resulting in that you've got too much "administration overhead". People that initially sees Magic's source code, are often shocked to see the sheer number of projects (40+), without realising that by segregating its projects to such an extreme extent, it's much easier to segregate teams into smaller more easily managed chunks of code, again resulting in that you can create smaller autonomous teams, not interfering with each other, making it easy to "feed each team comfortably on 2 pizzas".

Conclusion? If your git branches looks like "guitar hero", you're probably doing something wrong elsewhere in your organisation. Rethink the way you're working, find the underlying symptom, and watch your "x-mas tree automatically turn into a Redwood tree" ... ;)

Collapse
 
fabianaasara profile image
Fabiana Asara • Edited

git-rebase is still a mystery to me πŸ₯²scared to even use it

Collapse
 
joelbonetr profile image
JoelBonetR πŸ₯‡ • Edited

I use GitKraken Pro, I'm not a peasant πŸ˜‚πŸ€—

Collapse
 
tonyknibbmakarahealth profile image
TonyTheTonyToneTone
> commit
Enter fullscreen mode Exit fullscreen mode

It always wants me to write a comment.

Collapse
 
vinayvinay profile image
apssdcvinay

I struggled with git rebase a lot of times

Collapse
 
androizer profile image
Akshay Mahajan

Alot of common git commands are ok to grasp like merge, rebase, cherry-pick, reset etc. But the command I think I currently struggle upon is interactive rebase when people who don't understand where rebase excel and ruin the history with alot of merge commits.

Collapse
 
garrettmills profile image
Garrett Mills

A lot of submodules stuff feels... suboptimal for end-users. One that gets me occasionally:

  1. Clone repo with submodules & initialize submodules
  2. Edit file in a submodule and commit/push it
  3. Commit disappears into the ether.

This is because submodules check out a detached head instead of a branch, so committing on top of the head doesn't make the commit the new head of the branch... so next time you pull it disappears.

Collapse
 
ytjchan profile image
ytjchan

Can git reflog show the commit hash?

Collapse
 
ameliagapin profile image
Amelia Gapin

I will NEVER grasp submodules. Every time someone at work brings them up as a suggestion, I run away

Collapse
 
jwp profile image
John Peters

Visual Studio Code has a plug-in named GitLens. It is so good that I don't issue git commands any longer.

It includes rebasing,
auto resetting to any commit, changing the head pointer, full Visual commit history with code drill down ability to see modifications. Not to mention syncing, pushes and pulls, commits and branching.

Collapse
 
mondash profile image
Matthew Ondash

Oh for sure! Interactive rebase with GitLens is the bees knees! And managing branches and stashes has never been easier. Pair it with the Git Graph extension and it's a whole new world :D

Collapse
 
jwp profile image
John Peters

It's helped me out of terrible messes I did to my local and remote repos many times.

Collapse
 
wormholecowboy profile image
Wormhole Cowboy

Kept forgetting to pull after adding a readme on Github. Then I wouldn't be able to push because of conflicts, so I had to learn how to use rebase.

Collapse
 
roneo profile image
Roneo.org

git commit --fixup

Collapse
 
sagefright profile image
sagefright

WTF?1 Just read about this as a result of your comment. What is the point?!

Collapse
 
supportic profile image
Supportic

git reflog

Collapse
 
matthewsalerno profile image
matthew-salerno • Edited

revert has screwed me over a couple times. I think I get it now but it took a couple painful lessons to learn that it was not "revert back to this commit" but was actually "revert this commit and keep future commits." I ended up deleting my working commits and keeping my broken ones πŸ˜‚πŸ₯²πŸ˜­

Collapse
 
sagefright profile image
sagefright

Agreed, I recently went on a rant about revert and got it all out of my system.
twitter.com/AndyHails/status/15103...

Collapse
 
sandeshsapkota profile image
sandeshsapkota

do we have this command in git ! really ?

Collapse
 
matthewsalerno profile image
matthew-salerno

Yup the man page even tells me not to do exactly what I did. Although it's not as bad as I made it sound as it doesn't actually remove the commit, it just makes a new one that makes it as if the commit never happened.

Collapse
 
reactifystudio profile image
Reactify

Git stash 🀣🀣

Collapse
 
raj5036 profile image
Raj Karmakar

Git Stash is my best friendπŸ˜†πŸ˜†