A Useful Git Command

Originally published at: https://tech.staging.frocentric.io/2022/06/03/a-useful-git-command/

Originally posted by James Midzi to A Useful Git Command As a developer version control is something that is most likely in your wokflow. If not, you should really consider taking the time to incorporate it. The most common git commands are git init – initialise an empty git repository git add – adds file(s)…

1 Like

For those who prefer GUIs, git-cola and VS Code also allow you to select the lines that you want to stage.

1 Like

Oh? Didn’t know about that one. I’ll be checking it out. Thank you

Nice one, @Ose. I use a commercial client called Tower, which has been well worth the investment for me over the years, but will be checking out git-cola as a free option for my students and other folks looking for a GUI client.

Ooh, I hadn’t heard of Tower – I’ll check it out. git-cola isn’t a complete solution unfortunately – you can only use it to stage, commit and view diffs for your latest changes. I use gitk to view the history, but I think it’s Linux-only. There’s a list of free GUI clients here though: Git - GUI Clients (side note: I’ve only just realised that this forum automatically fetches web page titles and displays them in place of URLs – nice feature!).

Isn’t GitHub Desktop a good solution for Windows & Mac users? VS Code’s source control tab looks pretty comprehensive too, but I haven’t got into the habit of using it yet. Do you not like it, or does it just not do everything you need?

Oh actually, it looks like gitk is available on Windows after all. But git-cola + gitk isn’t a complete solution either.

So I used to use GitHub Desktop on Windows, but when they released Tower for Windows (was originally Mac-only), I flipped to that for the consistency and broader functionality. VS Code is fine for regular commits, pulls and pushes, etc but whenever I want to do anything more complex, like merging, resolving conflicts or managing PRs, I switch into Tower.

They recently updated the VS Code Git UI in a way that I find slightly less intuitive and earlier this week, I ended up accidentally committing a database backup that contained some production application keys. :grimacing: I only realised when I received an automated email from one of my service providers saying they’d revoked my key as they’d detected it online. I then had to go through the rigmarole of cleaning my repo to scrub the offending file (now mulling posting a write-up about the process).

Not only that, but if you post a URL on a line by itself, you get a lovely onebox like this:

Ah ok – I thought VS Code could be used for merge conflicts too, but I’m not sure if I’ve ever actually tried (the nice thing about working on my own is that it’s pretty hard to create merge conflicts!). In my old job, I used meld or kdiff3 to resolve conflicts, but it felt like their integration with git was a bit ropey (either that or my understanding of git was/is ropey :grimacing:). I think the main reason why I haven’t taken to doing source control in VS Code is because it visually overwhelms me with features and unfamiliar icons, and I can’t be bothered to keep mousing over each icon until I’ve memorised what the ones that I care about look like. Using 3 different GUI tools isn’t ideal, but they all feel simpler and more intuitive.

Oh wow, that’s impressive. I’m guessing this must be a common accident, for them to have implemented that.

Awesome! :clap:t5: :clap:t5: :clap:t5:

Oh no, it can absolutely be used to resolve merge conflicts and it has a fairly nice UI for that:

Can definitely identify with this. Even though VS Code is my primary editor, I still just find some features harder to discover and use then switching context to Tower.

I guess so! What really caught me by surprise was the fact that it was identified in a zipped backup, so not only did they scan the repo for plaintext instances, but they also delved into the archive and scanned the contents as well! :exploding_head:

1 Like