Open Side Menu Go to the Top
Register
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

08-15-2018 , 10:48 AM
Quote:
Originally Posted by Grue
I heavily lean on sourcetree for certain use cases. CLI stalwarts: please tell me how to directly compare 2 different commits diffs? Because in sourcetree its 2 clicks while holding cmd.
Code:
git diff <old commit> <new commit>
You can reference the commits by SHA or relative to HEAD.

Quote:
Originally Posted by Grue
Also checking out commits (detached head) is ridiculously easier. Both of which I do daily while doing PR review etc.
How is it ridiculously easier?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-15-2018 , 10:52 AM
I assumed he didn't mean "git diff <commit_a> <commit_b>" but I almost asked anyway
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-15-2018 , 12:38 PM
I know how to do a git diff but that involves tediously finding and copy and pasting giant commit hashes after a git log and then hitting space x number of times to hopefully find what you want as opposed to clicking on the file. Checking out a commit in sourcetree is double clicking as opposed to more copy paste of hashes.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-15-2018 , 04:34 PM
Quote:
Originally Posted by :::grimReaper:::
Interesting stuff suzzer. I wish there was a documentary on old school source control.



It's not that intimating. And the terminal is the opposite of painful. To me, a GUI would be painful and total amateur hour. Most of the git commands are:

status
log
add
commit
reset
rebase
branch
checkout
diff
grep
stash
fetch/pull
push
merge

(that was more than I thought, but it's pretty intuitive, not blind memorization)
gui is way better for merge conflicts and viewing commits/prs (use GitLens).

also, I like committing in a single key stroke rather than add . then commit -m "blahblahblah"

command line is better for log, checking out whatever old commits or branches, especially stash and rebase. also undoing multiple commits.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-15-2018 , 04:35 PM
I believe the git command you're looking for is git cherry-pick Suzzer. I use it all the time but not in the way you're mentioning.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-15-2018 , 04:42 PM
I force pushed to master for the first time yesterday. It seemed to have the desired effect.

A bunch of large binary files were accidentally committed to master, making the remote unworkable. The bad commit is now headless, so should get killed by GC. Although it seems to kill GC rather than vice versa.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-15-2018 , 08:23 PM
Sourcetree is just a front-end for CLI git, so there must be commands for everything it can do, it's just a pain to remember all the commands options and paths to files.

Also by using Sourcetree, you're not giving up CLI. You can swap between the two easily and type or mouse when you need to.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-15-2018 , 08:36 PM
Something that made me lol hard in last week's Hacker Newsletter was lazygit, for this tagline:

Quote:
Are YOU tired of typing every git command directly into the terminal, but you're too stubborn to use Sourcetree because you'll never forgive Atlassian for making Jira? This is the app for you!
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-15-2018 , 09:43 PM
Quote:
Originally Posted by Grue
I know how to do a git diff but that involves tediously finding and copy and pasting giant commit hashes after a git log and then hitting space x number of times to hopefully find what you want as opposed to clicking on the file. Checking out a commit in sourcetree is double clicking as opposed to more copy paste of hashes.
1. You don't need to ever mess around with the long git hash. Look at `git log --oneline`. Better, `git log --decorate --pretty --oneline` is what I use. You can get away with the 7 character one.

2. You can specify the commits relative to HEAD, e.g. `git diff HEAD~5 HEAD~3`. Use an alias to abbreviate this.

3. If the old commit is a branch, you can use name the branch, e.g. `git diff master HEAD~3`. Use tab complete on branch names.

4. New commit defaults to HEAD, so you don't have to specify it if that's what you want, e.g. `git diff master HEAD` is the same as `git diff master`

But as I already mentioned to suzzer, I look at big diffs (e.g. merge requests) in Gitlab, and side-by-side, which is not something the cli can do natively to my knowledge.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-15-2018 , 09:47 PM
Quote:
Originally Posted by Victor
also, I like committing in a single key stroke rather than add . then commit -m "blahblahblah"
Use `git commit -am`
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-15-2018 , 09:56 PM
or in my case, git commit -anm..
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-16-2018 , 03:54 AM
What exactly does -n do?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-16-2018 , 07:53 AM
No verify i.e. skip pre-commit git hooks. In my case its a (self inflicted) lint:all hook.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-16-2018 , 11:52 AM
ugh you have commit hooks? that seems like overkill. we have push hooks which is annoying. seems that only running hooks on merge is best imo.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-16-2018 , 12:56 PM
You can have very basic commit hooks. We have a hook that adds a change-id for Gerrit.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-16-2018 , 02:12 PM
Pre-commit must pass lint-all. Pre-push must pass all unit tests. I made it and love them . Though I told my team to feel free to use git commit -n and git push --no-verify on their own branches prior to doing a pr. Haven't had any complaints.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-16-2018 , 02:26 PM
I like that system.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-16-2018 , 03:25 PM
Since we're talking about git and aliases in general, here is part of what my current one looks like. I have some for git diff of various branches (master, main dev branch, etc) but those didn't fit in first page.

** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-16-2018 , 07:08 PM
pr hook should be unit tests, lint and build. Then no-verify when addressing pr feedback and whatever. Then run hooks on merge.

We don't do that and so many devs waste a lot of time on pushing and amending prs.

Also our hooks take like 20mins.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-16-2018 , 07:10 PM
Imo commits are personal. I mean, you gotta commit to change branches. Crazy to force that.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-16-2018 , 08:16 PM
we have one that runs on every commit to master

runs unit tests, blackbox tests, and some performance regression tests.

but sometimes even the jobs that run on git hooks is bugged. This week I found out one of our jenkins jobs was silently failing, probably for weeks now. I told the girl that wrote the script, she blamed the infra guy, the infra guy blamed her, and my boss lost his ****.

Ended up being a problem with using a deprecated linux command.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-16-2018 , 08:21 PM
i have a question for you guys which will sound totally stupid probably -

How does your guys' work schedule work? Do you need to request days off? Do you get a certain amount per year? Are your work hours set, or do you come and go day to day as you please?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-16-2018 , 09:13 PM
Quote:
Originally Posted by jmakin
i have a question for you guys which will sound totally stupid probably -

How does your guys' work schedule work? Do you need to request days off? Do you get a certain amount per year? Are your work hours set, or do you come and go day to day as you please?
My current job has "unlimited vacation time" which really means "most people take less days than if we just gave them 3 weeks." I give 2 weeks heads up for anything longer than 3 or so days, if I wanted to take tomorrow off I'd just IM my boss. For the most part I tell them when I'll be off, I don't have to ask. I have been politely asked to change dates once or twice in my career.

80% of my jobs have been fixed amount of vacation time, usually about 3 weeks.

Work hours are more or less at my discretion but there's a spoken rule that there needs to be significant overlap in hours so anyone whos' working will typically be working during 10am-3pm. But today for example I came in at about 10am, yesterday I started work at 7am.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-16-2018 , 09:58 PM
All 3 companies I have been at have had a set amount of days (both PTO and sick days which has always been an honor system to use), and a system for logging them. My current company switched to unlimited, and I don't see anyone using less tbh. In fact most of us plan to use 20ish days, whereas it was 15 prior.

Same thing with work hours as Rusty. Although it is kind of unspoken to be in before 10 at my current job and it was directly set as you have to be in the office between 9:30 and 4 at my first.

My 2nd job was insanity. We had people that came in at 6am and people that came in at 2pm.

All 3 were fairly opposed to remote work, though I do 1-2 days remote currently because my manager is into remote work
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
08-17-2018 , 12:48 AM
I had a boss who was opposed to WFH but didn't want to outlaw it, so he'd just schedule meetings during when I would usually WFH. (He knew I did not like to attend meetings remotely if I could avoid it)
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote

      
m