DEV Community

Megan Risdal for Stack Overflow

Posted on

SELECT Post FROM Stack Overflow Questions WHERE Topic = "git" ORDER BY Votes DESC;

Recently, one of my friends, Jamie Hall, wrote a really great, practical tutorial titled "Get good at git". In it, he introduces the basic workflows you need to know to use the version control system everyone "loves to be hated by" (his joke, not mine). Not only is it a lovely introduction to git, this paragraph really resonated with me:

In practice, everyone [screws] up constantly. I’m talking about professional software engineers, with many years’ experience, totally [screwing] up their work through unforced errors and dumb mistakes.

Problems with git are so common that Katie Sylor-Miller created a website explaining how to get out of a specific git mess in plain English.

Knowing that the best place to find reassuring company with other developers totally screwing things up is Stack Overflow, I decided to have a look at the all-time top questions by votes to see how common git problems are. And it turns out that 5 of the top 10 most voted questions are about getting help with git.

If you've come across one of these questions (I know I have), you are very far from alone! I used DEV's new Stack Overflow liquid tag to embed the top git questions of all-time on Stack Overflow. Plus, on Stack Overflow you can now also click "share" and select "DEV" on any post.

#2 most upvoted question

I accidentally committed the wrong files to Git but didn't push the commit to the server yet.

How can I undo those commits from the local repository?

The only way seems to be to copy the edits in some kind of GUI text editor, then wipe the whole local…

#3 most upvoted question

I want to delete a branch both locally and remotely.

Failed Attempts to Delete a Remote Branch

$ git branch -d remotes/origin/bugfix
error: branch 'remotes/origin/bugfix' not found
$ git branch -d origin/bugfix
error: branch 'origin/bugfix' not found.

$ git branch -rd origin/bugfix
Deleted remote branch origin/bugfix (was 2a14ef7).

$ git

#4 most upvoted question

What are the differences between git pull and git fetch?

#8 most upvoted question

How do I undo 'git add' before commit?

10448

I mistakenly added files to Git using the command:

git add myfile.txt

I have not yet run git commit. Is there a way to undo this, so these files won't be included in the commit?

#9 most upvoted question

How do I rename a local Git branch?

10369

I don't want to rename a remote branch, as described in Rename master branch for both local and remote Git repositories.

How can I rename a local branch which hasn't been pushed to a remote repository?

In case you need to rename a remote branch as well:
How do

What about you?

Are there Stack Overflow questions about git you constantly reference? What are your biggest git hangups? Have you ever had any "oh crap" moments with git?

Top comments (7)

Collapse
 
simbo1905 profile image
Simon Massey

There is a comsci paper about a study into the usability issues with git written up at What's wrong with Git A conceptual design analysis

People often think that a tech having a lot of questions on stack overflow shows it is mainstream so the more the better. What folks don't seem to think about is that a tech that has a lot of traffic might be failing it's community by being overly complex and giving a poor user experience.

There are a few technologies I use that have very little traffic on stackoverflow. I think that is because they are very well designed and documented. It would be nice if stackoverflow could somehow celebrate projects that get it right. Not sure how that could work though 🤔

Collapse
 
mrisdal profile image
Megan Risdal

Yeah, that's a really good observation! For those technologies, it would probably have to be different ways of engaging beyond technical Q&A. Even among languages/technologies that are well represented on Stack Overflow, it's probably the most unintuitive aspects make up the top issues. For example, pip installing TensorFlow is probably (hopefully) not how machine learning engineers are spending most of their time working with TF, but it constitutes a lot of the questions/pageviews.

Collapse
 
wannabehexagon profile image
ItsThatHexagonGuy

That is an interesting thought, would you mind sharing some of your knowledge regarding alternatives to git, and/or any other alternatives to popular technologies that do a better job? I'd love to read about them.

Collapse
 
simbo1905 profile image
Simon Massey

To really get your head around git it helps to read the open source book Git From The Bottom Up. It explains the internal data structures from the bottom up. This gives you the amazing superhuman power understanding what you could have done wrong and what you might need to do to fix things. Before I had this knowledge I used to often zip up my local folder before trying to fix things due to fear, uncertainty and doubt. Now I still have to search for advanced things but find it much easier to see which answers match my situation and will fix it.

Collapse
 
tttfifo profile image
Todor Todorov

Hi Megan,

I am not some master of git - and I am sure I have already referenced to all the questions you present in the current post :)

While using git on a daily basis I try to get into the head of Linus Torvalds and I try to think like him :) This is fun :)

Collapse
 
moopet profile image
Ben Sinclair

My random data point to add is that my only (I think) answer about git on Stack Overflow has many times more votes than any other answer I've given.

Collapse
 
waylonwalker profile image
Waylon Walker

This makes for a good quiz, how many can you answer?