3

Which git commands do you struggle with?

 2 years ago
source link: https://dev.to/ben/which-git-commands-do-you-struggle-with-4oj3
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
Cover image for Which git commands do you struggle with?
Ben Halpern

Posted on Apr 20

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. 😄

Discussion (38)

pic

Collapse

Expand

Collapse

Expand

Collapse

Expand

I struggle with the existence of git cherry-pick :p

Comment button Reply

Collapse

Expand

Collapse

Expand

Rebasing: concept is clear, I can do a dead simple rebase, but rebasing in general is a struggle, so much that I almost always end up merging. My bad, I know.

Comment button Reply

Collapse

Expand

I support you, it's okay to merge. (I also don't really understand rebase)

Comment button Reply

Collapse

Expand

Rebase is so underrated but also so hard to grasp, which is why also often use merge or squash merges.

Comment button Reply

Collapse

Expand

It's not so much the individual commands as the entire philosophy. And the multiple commands that do the same thing. Or nearly the same thing. Or almost the same command that does something entirely different. So you're left feeling like "You're in a room with multiple exits, all the same".

Comment button Reply

Collapse

Expand

Author

Apr 20

Have you considered using a tool or abstraction that helps? Just curious.

Comment button Reply

Collapse

Expand

I use TortoiseGit mostly. And eGit in Eclipse. And I used to use SourceTree. They all help a bit. But when things go screwy, I inevitably end up back at the command line.

Comment button Reply

Collapse

Expand

At least when you enter a wrong command you don't get eaten by a Grue

Comment button Reply

Collapse

Expand

The commands which I don't use often!

Comment button Reply

Collapse

Expand

Collapse

Expand

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 😂🥲😭

Comment button Reply

Collapse

Expand

do we have this command in git ! really ?

Comment button Reply

Collapse

Expand

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.

Comment button Reply

Collapse

Expand

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.

Comment button Reply

Collapse

Expand

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.

Comment button Reply

Collapse

Expand

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

Comment button Reply

Collapse

Expand

Can git reflog show the commit hash?

Comment button Reply

Collapse

Expand

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.

Comment button Reply

Collapse

Expand

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

Comment button Reply

Collapse

Expand

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

Comment button Reply

Collapse

Expand

Since I code pretty much every project on my own, I regularly use the git rebase command which is a very powerful git command since it gives you the flexibility to modify local commits. Although hard to learn initially, it does get easier to use over time.

However, I wouldn't recommend to use such git commands in a group project setting as that could likely lead to "loose ends" in the git repo history (i.e. branch conflict issues) which can be a massive pain to deal with if you ask me.

Comment button Reply

Collapse

Expand

I pushed a commit straight into main and tried to undo this action. Since this my hair is white.

Comment button Reply

Collapse

Expand

Collapse

Expand

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.

Comment button Reply

Collapse

Expand

git rebase. On a larger level it can be quite annoying how different projects handle the way they want to handle git history only for it to be rarely referenced.

Comment button Reply

Collapse

Expand

Had a hard time wrapping my head around git rebase after learning git merge.

Comment button Reply

Collapse

Expand

well it was,
git stash, which makes a temporary, local save of your code
& git bisect, a function that allows you to hunt out bad commits
but now I don't :D

Comment button Reply

Collapse

Expand

git-rebase is still a mystery to me 🥲scared to even use it

Comment button Reply

Collapse

Expand

Collapse

Expand

> commit

Enter fullscreen mode

Exit fullscreen mode

It always wants me to write a comment.

Comment button Reply

Collapse

Expand

It's more about the concept of conflicts instead a specific command.

Comment button Reply

Collapse

Expand

Collapse

Expand

Collapse

Expand

Git Stash is my best friend😆😆

Comment button Reply

Collapse

Expand

I struggled with git rebase a lot of times

Comment button Reply


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK