Live data from Hacker News

New in Git: switch and restore

banterly.net

351–360 of 550 posts

Re: New in Git: switch and restore

#351

Earlier quoted context omitted.

I'd rather use a "visual tool" to visualize

No apparently that means you don’t know what you’re doing, and you’ll corrupt the repo, and you’re not a real software developer so we’ll come to your desk and rip up your I’m A Very Serious Professional card.

It's funny, because most devs that are pro CLI for these kind of things, are actually unable to operate vi, or install any server / container without installing a complete desktop environment.

Let's all go back to the ed line editor

Re: New in Git: switch and restore

#352

Earlier quoted context omitted.

This is my main gripe about git, it’s literally a tool created to suit the guy managing the linux kernel development via mailing lists… What proportion of junior developers are even tangentially working on anything resembling that? Even if it’s exceptionally wonky, I have absolutely no problem introducing git to new devs, as long as it’s alongside a graphical representation (sourcetree or some ide-extension), and as…

Yeah, hence see the criticisms of git from completely different sides from fossil devs on one hand and pijul dev(s?) on the other. Git probably has its place, but only on very specific, large scale projects, with a crack core team and hundreds of drive-by contributors ?

> Git probably has its place, but only on very specific, large scale projects, with a crack core team and hundreds of drive-by contributors ?

So, hypothetically, if that were the case, what is the recommendation for Small/Medium web agencies?

Re: New in Git: switch and restore

#353
post #156

Earlier quoted context omitted.

It was in a very old fashion and regulated working environment where developers and testers aren't allowed to install whatever they want. Software installers can be whitelisted after a review is done. It included things like: licence OSS vs enterprise, support, community, or even more banal things like stars on github. Adding new software to a list could take literally months - like in case of git GUI client. Sublime…

What was their justification for being like that? Sometimes I read these things and end up saying to myself "Wow, that company just literally hates being productive"

>What was their justification for being like that?

The more tools people are allowed to install and use, the less standardised software development. Meanwhile we didn't even have common source code formatting pattern and single Java class could be formatted with tabs, 2 spaces and 4 spaces.

Re: New in Git: switch and restore

#354
post #241

Earlier quoted context omitted.

Seriously, seeing the commit tree laid out with colored lines is essential to me. A glance at the interface lets me know exactly what state the repository is in. Just like you say, it's less mistakes . Which is precisely one of the benefits of good UX. Going from SourceTree back to the command line would be a huge step backwards for me. I still use the command line sometimes because there's advanced stuff SourceTree…

Yeah, viewing a changeset and staging only some files or just parts of files is really important to my workflow. Sometimes I leave myself comments or skip tests locally and I have no intention of committing those changes. Using a tool like sourcetree to review, add, and commit only the lines I want is very helpful and saves me time. I do use the command line for everything else, though. Well except interactive rebasi…

I’m in the same camp, often staging is easier to handle with a GUI, particularly if you want a partial staging.

But then again, there is always git add -p

Re: New in Git: switch and restore

#356

Earlier quoted context omitted.

To the op's point, using git is not the act of coding or in this example making cabinets. I think it would be more akin to a work flow used by a cabinet maker and I think people would be less likely to look down on one that has an idiosyncratic work flow. It may not be the most optimal work flow, but they can get the job done well following their methods. I don't subscribe to that thinking and I try to optimize and i…

It's about tools . Git (and revision/version control more generally) is a tool available for you to use when developing software. The questions for me are: do you use the tool? do you understand the tool? I think it's fine if someone says "I don't use that tool". I personally think that they are making their life harder and their software probably worse, but that seems like a valid choice. What I have a difficult tim…

Surely some tools have to be more important than others tho and not knowing some tools impacts some jobs less. Is git a saw for woodworking? Or is it a tool chest that has a drawer for a saw? If you need to use a thousand different tools, the tool chest becomes more important (the analogy doesn't map well there but it seems similar to working on a bunch of repos that have a bunch of branches or one repo with one branch). If you only need a handful, it seems like it would impact your job less.

Re: New in Git: switch and restore

#357

Earlier quoted context omitted.

First of all, using "noob" like that is offensive. Everyone's a "noob" at some point. And if that's how you talk and treat people, I probably wouldn't want your help. And second, what exactly mystifies you about what e.g. SourceTree menu commands do? They map clearly and intuitively to CLI commands. If you have "no idea" what it's trying to do then you're not even trying to be helpful. You're just being condescending…

I get you disagree with the GPs post but “noob” isn’t offensive. What’s offensive is their lack of support for colleagues (which reads like a potential issue with their own ego: where they didnt want to be shown up in an unfamiliar UI). But their post reads exactly the same if you substituted “noob” for “newbie”, “junior”, “inexperience” etc. What we need to do is get passed this ridiculous mindset some have that not…

> which reads like a potential issue with their own ego: where they didn't want to be shown up in an unfamiliar UI > What there should be is shame ... those who don’t offer up their help to others

I read it more as, I don't want to be become L1 Tech Support for something I don't know either.

Re: New in Git: switch and restore

#358
post #241

Earlier quoted context omitted.

Seriously, seeing the commit tree laid out with colored lines is essential to me. A glance at the interface lets me know exactly what state the repository is in. Just like you say, it's less mistakes . Which is precisely one of the benefits of good UX. Going from SourceTree back to the command line would be a huge step backwards for me. I still use the command line sometimes because there's advanced stuff SourceTree…

Yeah, viewing a changeset and staging only some files or just parts of files is really important to my workflow. Sometimes I leave myself comments or skip tests locally and I have no intention of committing those changes. Using a tool like sourcetree to review, add, and commit only the lines I want is very helpful and saves me time. I do use the command line for everything else, though. Well except interactive rebasi…

Just in case you didn't know, there is git add -p (or --patch) which does precisely what you want: It splits your changes into small parts ("hunks") and allows you to specify whether to stage every hunk. I don't know your exact workflow in Sourcetree, but most likely git add -p is the CLI equivalent of the Sourcetree interaction you describe.

Bonus commands: -p/--patch also works for git stash (allowing you to stash only certain changes) and for git checkout (allowing you to discard only certain changes). Since I'm an Old School Git user I actually don't really know the restore/switch commands, but apparently git restore supports -p/--patch as well.

Another neat git add flag is -u/--update: The manpage is a little confusing on this flag, but essentially it makes git add ignore untracked files (it will only stage files that are already part of the repository). If you're like me, you have tons of files laying around in the project folder (e.g. benchmark results or local test input files) that you don't want to commit and yet don't want to add to the .gitignore file (since the files are really just temporary files, other users have no use for the gitignore entries). By using git add -u, you prevent adding them by mistake in a command like git add src/ and realizing a few weeks later that you accidentally added 10 MB of cat pictures to a bugfix commit. If you can identify with this story then git add -u is made for you.

Another bonus fact: If the temporary testing files mentioned in the last paragraph ever reach the status of permanent testing files, and they're still only useful to you personally (so adding them to gitignore doesn't make sense), Git has a little-known feature: You can add local ignore patterns (same syntax as gitignore) to .git/info/exclude (go ahead and check, this file most likely already exists in your Git repository). These patterns are not be part of the repository itself (you don't commit them), rather they act as local configuration. The idea is that you put exclude patterns that are valid for every user of the project (e.g. target/ for a Rust project) in .gitignore, and local exclude patterns for your IDE/editor configuration (.vscode/, .idea/ and friends) and similar files in .git/info/exclude.

In conclusion, I only every run a) git add -u $file (when I want to add all changes made to an existing file), b) git add -p $file (when I want to add only certain changes made to an existing file), or c) git add $new_file (when I consciously want to add a previously untracked file).

These three commands are all you need if you're in the camp of Git users that at least try to make every commit a good package (single, reasonably-scoped and atomic change). If you're in the git commit -a/"squash all intermediate commits into one single monstrous commit" camp then.. have fun with your cat pictures, I guess.

I hope that was at least a little bit helpful to someone.

May I ask why you drop into VS Code for interactive rebasing? Is it about resolving the merge conflicts, or editing the rebase command list? I'm just going to drop two more nice Git features here, but I'll stop myself now before I write too much: git commit --fixup= together with git rebase --autosquash, and git rerere (not a typo).

Re: New in Git: switch and restore

#359

A lot of comments along the lines of ‘why do people use instead of learning the commands’. For me, I used to use the terminal git, and I still do occasionally. But I use Sourcetree now for most things because I make less mistakes seeing the tree visually all the time. My job isn’t to use git, it’s to write specialist software. If I get the software written and the customer is happy, it doesn’t matter whether I use or…

>> My job isn’t to use git, it’s to write specialist software.

It's like a plumber complaining that his job isn't driving with a car and that he wants customers to pick him up or wait for him until he comes on foot or via public transport.

Re: New in Git: switch and restore

#360
post #359

A lot of comments along the lines of ‘why do people use instead of learning the commands’. For me, I used to use the terminal git, and I still do occasionally. But I use Sourcetree now for most things because I make less mistakes seeing the tree visually all the time. My job isn’t to use git, it’s to write specialist software. If I get the software written and the customer is happy, it doesn’t matter whether I use or…

>> My job isn’t to use git, it’s to write specialist software. It's like a plumber complaining that his job isn't driving with a car and that he wants customers to pick him up or wait for him until he comes on foot or via public transport.

A fairer analogy is that GP is saying, "I don't want to use a van to bring my stuff, but prefer a pickup truck." From the customer's POV, it makes no difference.
Post reply on HN