Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Oysters Autobio
Mar 13, 2017

New Yorp New Yorp posted:

Git (and dvcs in general) is 100% the wrong tool for this job. Beside being insanely complicated, it's unsuitable for storing revisions of non-text assets. Why invest the effort into shoehorning a tool to work with content types and work flows for which it is, by design, wholly unsuitable?

If you need document management, use a document management tool. There are tons out there and they all suck in their own special way, but using git would be 1000x worse.

Aside from the complexity, what do you think are the biggest drawbacks for it? If you worked off of it in a compatible format like Markdown which then could run a pipeline to use pandoc or something else to convert it to whatever other format you need, would it not work to show those kind of revisions?

I thought "by design" Git is used to store complicated revisions of text (code). If you were say, a collaborative team of researchers writing out a complicated paper, wouldn't the complexity of the tool be worth the added tracking of revisions, commentary and the ability to branch? Or say legislators/governance teams or whatever drafting complex policy/legal docs but want to be able to allow for contributions without fear of it messing up their originals (I guess Wikis have version control too but in highly bureaucratic organizations getting "approval" is sacrosanct unfortunately) and who need precise tracking of revisions?

Only other document management tools I've used is something like SharePoint which requires you to "check-in" entire document or "check-out" entire documents, but this completely prevents concurrent work. I guess merging together different branches could be difficult if you were collaborating off something line by line but couldn't Git merge easily enough text documents that different people were working off of say, different entire sections?

Also interesting would be to use some of the language-based linters people have developed that can automatically scan for things like style guides (i.e. readability, plain language use, lack of passive voice, etc.).

Maybe I'm conflating Git to just mean being able to do "version control with branching" along with using Markdown for What You Say Is What You Mean (WYSIWYM) so that you can focus on just the text and let automation handle all the templating and formatting junk that people get stuck in when writing in MS Word. Definitely agree that using Git as-is would be too clunky for this, so thats why I'm curious if anyone's modded something like Gitlab, stripped it away of the unnecessary parts and re-built it with things like a rich text markdown editor that could be used in MRs.

Adbot
ADBOT LOVES YOU

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Oysters Autobio posted:

If you worked off of it in a compatible format like Markdown which then could run a pipeline to use pandoc or something else to convert it to whatever other format you need, would it not work to show those kind of revisions?

Your average non-technical document author is not going to be using Markdown (or Latex). They're going to be using Word or some other binary format. For anyone technical enough to be using an actual diffable text format, just learning enough Git to be dangerous is enough.

This seems very much like an idea that doesn't have an audience combined with every problem looking like a nail.

Oysters Autobio
Mar 13, 2017

New Yorp New Yorp posted:

Your average non-technical document author is not going to be using Markdown (or Latex). They're going to be using Word or some other binary format. For anyone technical enough to be using an actual diffable text format, just learning enough Git to be dangerous is enough.

This seems very much like an idea that doesn't have an audience combined with every problem looking like a nail.

Yeah I guess you're right. I just want people to stop emailing random ad-hoc versions of Word documents, so the appealing parts of Git is the centralization, "single source of truth" and version control but none of those things are super unique to Git.

Unfortunately, most corporate enterprise document management software out there is just garbage so instead people are back to shared drives and email. I'm just gonna try and get people to use Confluence at least, thats maybe an achievable goal.

Tetraptous
Nov 11, 2004

Dynamic instability during transition.

Oysters Autobio posted:

Yeah I guess you're right. I just want people to stop emailing random ad-hoc versions of Word documents, so the appealing parts of Git is the centralization, "single source of truth" and version control but none of those things are super unique to Git.

Unfortunately, most corporate enterprise document management software out there is just garbage so instead people are back to shared drives and email. I'm just gonna try and get people to use Confluence at least, thats maybe an achievable goal.

I’m happy using Git with LaTeX for technical documents (Overleaf even has nice GitHub integration), but there’s no way normal people are going to work that way. Asking non-programmers to learn git is particularly insane.

Office 365 basically does what you ask for already, though. It keeps track of (and let’s you compare or roll back to) different versions of the same document, and stores all of that information in a centralized place with one “single source of truth.” It’s not Microsoft’s fault if your org isn’t using it! I doesn’t have great ways to do things like branches or merges, but it’s pretty cool and fairly seamless to collaborate in real time with other people.

FISHMANPET
Mar 3, 2007

Sweet 'N Sour
Can't
Melt
Steel Beams
Does anyone have a "recipie" for moving a file from one git repository to another, in addition to the commit/revision history of that file (including past names since the file I'm looking to move has been renamed).

I can find various guides saying various things, but they all seem to be for slightly different situations I'm in. I see lots of guides on moving a subfolder, but I don't want to move a whole subfolder, just a single file. That single file also happens to be in the root of the repository. The things I do find don't have much explanation around what each step is doing, so I'm having a hard time even modifying them to work with my situation, because I don't understand what they're doing in the first place.

Hughlander
May 11, 2005

FISHMANPET posted:

Does anyone have a "recipie" for moving a file from one git repository to another, in addition to the commit/revision history of that file (including past names since the file I'm looking to move has been renamed).

I can find various guides saying various things, but they all seem to be for slightly different situations I'm in. I see lots of guides on moving a subfolder, but I don't want to move a whole subfolder, just a single file. That single file also happens to be in the root of the repository. The things I do find don't have much explanation around what each step is doing, so I'm having a hard time even modifying them to work with my situation, because I don't understand what they're doing in the first place.

Assume you have RepoA that you want to keep and RepoB that you want the file from:

git clone repoB
git filter-repo --path thefileyoucareabout
git push

git clone repoA
git remote add repoB repoBURL
git merge repoB/master

That should do it?

FISHMANPET
Mar 3, 2007

Sweet 'N Sour
Can't
Melt
Steel Beams
I want to keep both repos, but I think that would destroy repoB?

necrotic
Aug 2, 2005
I owe my brother big time for this!

FISHMANPET posted:

I want to keep both repos, but I think that would destroy repoB?

RepoB still exists unmolested from wherever you cloned it…

Edit: can. Instead of pointing at the remote RwpoB from RepoA point at the local .git folder. Don’t push RepoB to it’s origin.

JawKnee
Mar 24, 2007





You'll take the ride to leave this town along that yellow line
I have a coworker who has changed their name, and would like to not see their old name in git commit graphs, Azure DevOps file history, etc. where they were the author of those commits.

Adding a .mailmap has addressed some other instances of this (e.g. git log) but is not respected most of the time it seems. This is for a large codebase with several years of commit history, and all of the options git provides here seem dangerous. Is there any third-party tooling anyone can recommend that solves this problem?

Tesseraction
Apr 5, 2009

You could put a wrapper around git-blame to iterate through .mailmap and replace the field? Using porcelain if necessary. Looking it up it seems plenty of people have said that they've just had to live with being deadnamed in version control, which is a little depressing.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
Changing the author name on a bunch of commits and then having everyone rebase their in-progress stuff on top of the new history is conceptually pretty simple, but coordinating it seems like a nightmare if you have more than a handful of people touching the repo.

ChickenWing
Jul 22, 2010

:v:

https://www.git-tower.com/learn/git/faq/change-author-name-email/ right at the bottom, there's a bit about filter-branch that should do what you want.

Same warnings about editing shared history, though - the author information is included in the commit SHA, so every time you change this you're creating a brand new commit and git will have to recreate every descendant commit.

Basically, it's 100% doable, but they'll have to have big time buy in from their team (or whoever owns the repo). Honestly, I'd assume that unless you're at a particularly progressive workspace, they're gonna have to live with being deadnamed

JawKnee
Mar 24, 2007





You'll take the ride to leave this town along that yellow line
Yeah, I've read that already - and also some additional stuff that warns against using filter-branch for perf reasons. My workplace is reasonably willing to entertain a fix for this, and small enough that I could reasonably ask everyone to check in their work at the end of the day for me to make changes - was just hoping this was more of a solved problem

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

JawKnee posted:

was just hoping this was more of a solved problem

Seems pretty solved to me. It's an unusual* requirement and the tool supports it if you really need to do it.

*I know people change their names when they get married all the time but it's just generally accepted that "we'll do it if it's not too much of an inconvenience" is the general attitude there; this is a case where I expect there would be significant backlash if the "too much effort, deal with it" attitude were invoked.

pseudorandom name
May 6, 2007

What tools aren't respecting mailmaps?

JawKnee
Mar 24, 2007





You'll take the ride to leave this town along that yellow line

New Yorp New Yorp posted:

Seems pretty solved to me. It's an unusual* requirement and the tool supports it if you really need to do it.

*I know people change their names when they get married all the time but it's just generally accepted that "we'll do it if it's not too much of an inconvenience" is the general attitude there; this is a case where I expect there would be significant backlash if the "too much effort, deal with it" attitude were invoked.

okay

pseudorandom name posted:

What tools aren't respecting mailmaps?

The big one for the moment is Azure Devops. This manifests in the Files > Contents view of any branch, the commit history graph, and I'm sure some other places

JawKnee
Mar 24, 2007





You'll take the ride to leave this town along that yellow line
Well, we ended up re-writing history. Took a while and some planning, and some organization. git filter-repo made making the changes themselves a breeze, with devops only being slightly annoying to handle

SporkOfTruth
Sep 1, 2006

this kid walked up to me and was like man schmitty your stache is ghetto and I was like whatever man your 3b look like a dishrag.

he was like damn.
Related to the above, kinda:

I have a local repo in a folder with something I put together, and now a team I work on wants me to add that stuff to a bigger repo as a folder (and then push it to the remote). How the gently caress do I do that?

Repo structure:

Repo A:
in folder /repoA/
Has branches main and feature/do-poo poo

Repo B:
in folder /repoB/
Has main and origin/main branches

What I want:
Folders:
code:
/repoB/
|
--> /repoA/
Desired RepoB history should have repoA/main and repoA/do-poo poo bolted to repoB/main's HEAD, but probably rename repoA/main to cool-thing.

I feel like git-filter-repo is the right way to do this, but my brain just isn't clicking with the docs.

edit:
To be a bit clearer, repoB has other branches and features, but they're very much localized to single project folders, and my new thing doesn't depend on any of that.

SporkOfTruth fucked around with this message at 17:09 on Jan 26, 2023

StumblyWumbly
Sep 12, 2007

Batmanticore!
And nobody wants to use a submodule?
Is repoA going to change much in ways repoB either does or doesn't want? ie, do you want to let folks check repoA out on its own?

SporkOfTruth
Sep 1, 2006

this kid walked up to me and was like man schmitty your stache is ghetto and I was like whatever man your 3b look like a dishrag.

he was like damn.
repoA is, for all intents and purposes, dead now outside the context of being used within repoB. I developed it entirely locally, and it will not be pushed to a remote ever, but the history needs to be preserved.

SporkOfTruth fucked around with this message at 04:54 on Jan 27, 2023

nielsm
Jun 1, 2009



I have a similar situation, except it's more like wanting to make a monorepo of several projects that will continue to be developed.

The plan I have right now is to move everything in each repo individually to a subdirectory as they should be structured after the combining, then replay the history of each repo into a new one, with branch names changed so they don't clash. Then at the end do an octopus merge between all the separate heads from each repo and end up with a single one.
I'd rather not have to bother with rewriting the history of all the original trees, but prefer to preserve everything.

Hughlander
May 11, 2005

I’ve done that years ago with got bfg and it’s not bad. What you want to do is use filter repo or bfg or whatever to rewrite history such that the path was always /repoA/file1 instead of /file1. Then when you are done with that in repoB you add repoA as a remote called repoA. And finally git merge RepoA/master. Now all history from A is in B

Ruud Hoenkloewen
Jan 24, 2020
This is very possibly a 'it's hard because you're not meant to do this' problem, though I'm not good enough at git to know for sure. We've got branches A and B, where B is quite far ahead of A. I want to make a new branch, C, that's based on A but also has commits from B if they were made by a certain set of authors. Their changes are spread throughout the repo. I can use git log to get the relevant commits without a problem. The issue is that there's several hundred commits I need to move over, and cherry-picking that many isn't ergonomic, since I have to manually fix a lot of merge conflicts that crop up.

I took a look at https://github.com/newren/git-filter-repo, and while it lets you interrogate commits for the author name with the 'commit callback' flag, it doesn't seem to let you throw them away based on that.

Any suggestions on the least-bad way to do this? Just suck it up and cherry pick everything?

Vanadium
Jan 8, 2005

Aren't both of these the same operation / will run into the same merge conflicts? Maybe you can mitigate the pain with git rerere but in principle you're starting with A and sequentially applying a subset of B either way, no?

raminasi
Jan 25, 2005

a last drink with no ice

Ruud Hoenkloewen posted:

This is very possibly a 'it's hard because you're not meant to do this' problem, though I'm not good enough at git to know for sure. We've got branches A and B, where B is quite far ahead of A. I want to make a new branch, C, that's based on A but also has commits from B if they were made by a certain set of authors. Their changes are spread throughout the repo. I can use git log to get the relevant commits without a problem. The issue is that there's several hundred commits I need to move over, and cherry-picking that many isn't ergonomic, since I have to manually fix a lot of merge conflicts that crop up.

I took a look at https://github.com/newren/git-filter-repo, and while it lets you interrogate commits for the author name with the 'commit callback' flag, it doesn't seem to let you throw them away based on that.

Any suggestions on the least-bad way to do this? Just suck it up and cherry pick everything?

If you always want B, you can do an interactive rebase, use -X to force a resolution strategy, and generate your todo list by simply tweaking your log output. If you don't always want B, then you can still do the interactive rebase, just manually fix merge conflicts instead of using -X.

Ruud Hoenkloewen
Jan 24, 2020

Vanadium posted:

Aren't both of these the same operation / will run into the same merge conflicts? Maybe you can mitigate the pain with git rerere but in principle you're starting with A and sequentially applying a subset of B either way, no?

Semantically yeah, the difference to me is practicality. My hope was to find some command that'd zip through everything and just leave me with the codebase at the end, in whatever mangled state that might be. Hopefully that makes sense.


raminasi posted:

If you always want B, you can do an interactive rebase, use -X to force a resolution strategy, and generate your todo list by simply tweaking your log output. If you don't always want B, then you can still do the interactive rebase, just manually fix merge conflicts instead of using -X.

I do always want B, so I'll give this a go and see how well forcing it to pick their changes works. Thanks!

TheBlackVegetable
Oct 29, 2006
Just started a new job, first week in. Cloned a repo and saw two developers committing to main - one with frequent, poorly worded commits, the other one having pulled, merged and discarded the other devs changes and pushed back up.

So. Yeah. I don't really have a question I guess except maybe how justified am I to immediately and unilaterally lock down main and require PRs with mandatory reviews? Anywhere between Totally and 100% Absolutely, right?

ChickenWing
Jul 22, 2010

:v:

TheBlackVegetable posted:

Just started a new job, first week in. Cloned a repo and saw two developers committing to main - one with frequent, poorly worded commits, the other one having pulled, merged and discarded the other devs changes and pushed back up.

So. Yeah. I don't really have a question I guess except maybe how justified am I to immediately and unilaterally lock down main and require PRs with mandatory reviews? Anywhere between Totally and 100% Absolutely, right?

100% justified, 0% chance of it sticking


"We can't get our work done like this we have to remove all this red tape"

:negative:

Ranzear
Jul 25, 2013

ChickenWing posted:

"We can't get our work done like this we have to remove all this red tape"

Don't dig up my past like this, except it was not sharing a single server root password in a google spreadsheet.

StumblyWumbly
Sep 12, 2007

Batmanticore!

TheBlackVegetable posted:

Just started a new job, first week in. Cloned a repo and saw two developers committing to main - one with frequent, poorly worded commits, the other one having pulled, merged and discarded the other devs changes and pushed back up.

So. Yeah. I don't really have a question I guess except maybe how justified am I to immediately and unilaterally lock down main and require PRs with mandatory reviews? Anywhere between Totally and 100% Absolutely, right?

Maybe they have a separate "developed" branch that they merge into when they are ready to release the code they've developed?

If everyone is a senior dev and depending on how the code is used, you can maybe get away with requiring PRs but not requiring approvals.

Che Delilas
Nov 23, 2009
FREE TIBET WEED

TheBlackVegetable posted:

Just started a new job, first week in. Cloned a repo and saw two developers committing to main - one with frequent, poorly worded commits, the other one having pulled, merged and discarded the other devs changes and pushed back up.

So. Yeah. I don't really have a question I guess except maybe how justified am I to immediately and unilaterally lock down main and require PRs with mandatory reviews? Anywhere between Totally and 100% Absolutely, right?

I mean, I'd start with a conversation about it, because as tempting as it is, doing something like this out of the blue as the FNG is going to define you to the people whose workflow you interrupt, and you're going to have an adversarial relationship with your teammates for a long time. You can make a strong argument about it, and maybe they'll be on board to improve the situation.

TheBlackVegetable
Oct 29, 2006

Che Delilas posted:

I mean, I'd start with a conversation about it, because as tempting as it is, doing something like this out of the blue as the FNG is going to define you to the people whose workflow you interrupt, and you're going to have an adversarial relationship with your teammates for a long time. You can make a strong argument about it, and maybe they'll be on board to improve the situation.

Never fear, I know well enough to approach carefully and avoid any sudden movements.

At the moment I'm focused elsewhere but my job is in fact in a lead role, so I'll be dealing with this at some point - my current plan is to get them there gradually and lead by example as I set up the new services I'm working on.

smackfu
Jun 7, 2004

Maybe lock down force pushes at least? Still annoying but if people are pushing junk commits already shouldn’t be that much friction.

lifg
Dec 4, 2000
<this tag left blank>
Muldoon
You can make some noise now and have some conversations with your boss about this. Then wait. Then if something goes wrong that a nicer process would have solved you’ll be well positioned to make the change.

mondomole
Jun 16, 2023

Having a locked down main branch with code reviews seems to be a pretty low bar. But if it's really all that contentious, you can coax them in by focusing on the "release process" instead of their commit workflow. So for example, introduce a branch called "production" and, well, nobody is using it right now so might as well add some branch protection rules. They can continue to use their existing workflow to write and push and share quickly on main. The first few times you make a release, you can do the pull request yourself to go from main to production with a nicely written summary of all of the changes since last release. Once they're used to seeing you do that, slowly have them start to do the same.

This is really just semantics, making production the real main and main some development branch, but it might come across better as "here's some entirely new thing we can do to get release notes written down" as opposed to "here's how we're going to change something you're already doing."

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice
Speaking of pushing directly to main: in GitHub, is there a way to allow commits to a branch (main or otherwise) unless a certain file was changed, in which case it would require a PR? e.g. I can push a commit that changes a.txt and b.txt, but if that commit also contained changes to c.txt, it would fail and I'd have to PR.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Lumpy posted:

Speaking of pushing directly to main: in GitHub, is there a way to allow commits to a branch (main or otherwise) unless a certain file was changed, in which case it would require a PR? e.g. I can push a commit that changes a.txt and b.txt, but if that commit also contained changes to c.txt, it would fail and I'd have to PR.

You're looking for something called a pre-receive hook.

The Fool
Oct 16, 2003


In ADO you can run a pipeline on PR, and require that pipeline passes as a build validation step, then you can put whatever validation logic you want in there.

It looks like required workflows are the equivalent feature for github actions, but that is in private beta right now.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

The Fool posted:

In ADO you can run a pipeline on PR, and require that pipeline passes as a build validation step, then you can put whatever validation logic you want in there.

It looks like required workflows are the equivalent feature for github actions, but that is in private beta right now.

That's not going to prevent a commit from being pushed in the first place. That's the ask. It comes up a lot.

Adbot
ADBOT LOVES YOU

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

New Yorp New Yorp posted:

You're looking for something called a pre-receive hook.

Ah ha! Thank you. I could not google anything that returned this. Much apprecated!

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply