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
o.m. 94
Nov 23, 2009

Thanks! CTRL+W into the buffer and :q seemed to break the terminal when I tried, but I'll have a fiddle.

Adbot
ADBOT LOVES YOU

chippy
Aug 16, 2006

OK I DON'T GET IT
In Git, is there a quick/easy way of merging a branch into master, and if there are any conflicts, to automatically take the version of the file from the branch I'm merging in?

Basically, I need the contents of the other branch to become the new master branch, but retaining commit history etc. Is strategy=ours what I need here?

Less Fat Luke
May 23, 2003

Exciting Lemon
I think strategy uses the context of whatever branch you're in, which would be the merge target so you're probably looking for strategy=theirs.

aerique
Jul 16, 2008
Who here is using Git in a larger organization with more than, say, 50 or 100 developers? Do you use something like GitLab for managing users and repositories?

ToxicFrog
Apr 26, 2008


chippy posted:

In Git, is there a quick/easy way of merging a branch into master, and if there are any conflicts, to automatically take the version of the file from the branch I'm merging in?

Basically, I need the contents of the other branch to become the new master branch, but retaining commit history etc. Is strategy=ours what I need here?

You're asking for two different things here.

"merge a branch into master, and if there are any conflicts, automatically take that branch's version": git checkout master && git merge -X theirs other-branch. The -X theirs tells the default merge strategy to proceed normally except when conflicts are detected, which will always be resolved in favour of the branch you're merging in.

This is not the same as "I need the contents of the other branch to become the new master branch", which implies that you want to throw away all changes made by master including non-conflicting ones. For that, the natural thing to do would be to use the 'theirs' merge strategy (-s theirs, not to be confused with the 'theirs' merge option -X theirs) -- but it was removed several versions ago for some reason. The git devs recommend using git reset instead, but that'll throw away the history you want to keep.

Probably the easiest workaround is something like:
code:
git checkout other-branch
# merge master into this branch and throw away the changes
git merge -s ours master
# fiddle the branch heads so it looks like this branch got merged into master instead
git branch -f master
git reset --hard HEAD^

aerique posted:

Who here is using Git in a larger organization with more than, say, 50 or 100 developers? Do you use something like GitLab for managing users and repositories?

I am (both here and at my previous job), but probably not in a way that helps you. In both places we use Perforce as the backend and then individual developers use git locally - at the previous job using git-p4, and here using a custom git<->p4 bridge that also integrates with stuff like our code review tools.

It's actually quite nice, but it also completely avoids answering the question of "how do you scale git to a large organization" by treating it as a single-developer productivity tool instead.

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

aerique posted:

Who here is using Git in a larger organization with more than, say, 50 or 100 developers? Do you use something like GitLab for managing users and repositories?

We have ~60 developers using Git in our organization. Currently we're on GitHub, but we have plans to move off to something else (maybe Stash, we already use Jira).

brae
Feb 2, 2006

aerique posted:

Who here is using Git in a larger organization with more than, say, 50 or 100 developers? Do you use something like GitLab for managing users and repositories?

Raises hand. Our organization has about 150 developers, our source control is all on GitHub (github.com even, not GitHub Enterprise). We don't have any plans to migrate.

Dylan16807
May 12, 2010

ToxicFrog posted:

For that, the natural thing to do would be to use the 'theirs' merge strategy (-s theirs, not to be confused with the 'theirs' merge option -X theirs) -- but it was removed several versions ago for some reason. The git devs recommend using git reset instead, but that'll throw away the history you want to keep.

Probably the easiest workaround is something like:
code:
git checkout other-branch
# merge master into this branch and throw away the changes
git merge -s ours master
# fiddle the branch heads so it looks like this branch got merged into master instead
git branch -f master
git reset --hard HEAD^
Apparently the 'theirs' merge strategy was removed because they don't like that workflow. If you want to keep that unused history you're supposed to stick it in a different branch: http://marc.info/?l=git&m=121637513604413&w=2

But if you want to do it anyway, how about this for a workaround:
code:
git checkout master
git merge --no-commit other-branch
git checkout other-branch . #blow away all differences
git commit

NOTinuyasha
Oct 17, 2006

 
The Great Twist

brae posted:

Raises hand. Our organization has about 150 developers, our source control is all on GitHub (github.com even, not GitHub Enterprise). We don't have any plans to migrate.

Bet it's a lot of fun when Github.com goes down for hours at a time, like yesterday. We use Github too but we're only three developers so our budget is tight, if we were any larger we'd totally rather have our own Gitlab server rather than be subject to Github's occasional but extremely annoying service problems.

Steve French
Sep 8, 2003

Github's permissions model is also sort of garbage, which can be an issue for an even sort of small organization.

brae
Feb 2, 2006

NOTinuyasha posted:

Bet it's a lot of fun when Github.com goes down for hours at a time, like yesterday. We use Github too but we're only three developers so our budget is tight, if we were any larger we'd totally rather have our own Gitlab server rather than be subject to Github's occasional but extremely annoying service problems.

I try not to let deploying our software/service depend on a third party service (like GitHub) where possible, so generally it's not a huge issue when GitHub goes down although I can see how it'd be frustrating. Anyway, it works well for us, but I've heard good things about Gitlab as a self-hosted solution.

Space Kablooey
May 6, 2009


Git works pretty well for text files, as every programmer here that uses it knows, but is there any other VCSs more suitable for other types of files, say images or 3D models?

Jethro
Jun 1, 2000

I was raised on the dairy, Bitch!
Perforce is usually the answer to the "where do I put large binaries?" question.

apseudonym
Feb 25, 2011

necrotic posted:

We have ~60 developers using Git in our organization. Currently we're on GitHub, but we have plans to move off to something else (maybe Stash, we already use Jira).

We have a whole lot of devs on a huge project. We use gerrit.

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

NOTinuyasha posted:

Bet it's a lot of fun when Github.com goes down for hours at a time, like yesterday. We use Github too but we're only three developers so our budget is tight, if we were any larger we'd totally rather have our own Gitlab server rather than be subject to Github's occasional but extremely annoying service problems.

This was a problem for us when our deploy system simply checked out code from github.com on all 500+ of our servers.

We build a slug on one box and ship it out to the rest now. Amazing how many problems that solved.

aerique
Jul 16, 2008
Thanks for the answers so far. I'm kind of surprised to hear larger companies storing their source code at external parties like GitHub. Not from a Git perspective (it is a DVCS after all) but more from a legal / security perspective.

Edison was a dick
Apr 3, 2010

direct current :roboluv: only

HardDisk posted:

Git works pretty well for text files, as every programmer here that uses it knows, but is there any other VCSs more suitable for other types of files, say images or 3D models?

From what I've heard, the gaming industry is sticking with SVN for this.
You can do large binaries with git-annex or git-fat though.
git-annex requires more infrastructure, but with the git-annex-assistant, you can make it into a private dropbox.
git-fat only requires you being able to run rsync somewhere.
shameless plug time
gitano is currently working on having an rsync repository with every git repository, to make it easier to use git-fat, and be able to apply the same access control rules for git repositories to the rsync repository.

Hughlander
May 11, 2005

necrotic posted:

This was a problem for us when our deploy system simply checked out code from github.com on all 500+ of our servers.

We build a slug on one box and ship it out to the rest now. Amazing how many problems that solved.

How do you keep that up to date vs github? IE: I'm an engineer I push to github and want to see a build kicked off within seconds. Does kicking off the build start with the slug pulling from github then notifying the 500+ servers?

ToxicFrog
Apr 26, 2008


Dylan16807 posted:

Apparently the 'theirs' merge strategy was removed because they don't like that workflow. If you want to keep that unused history you're supposed to stick it in a different branch: http://marc.info/?l=git&m=121637513604413&w=2

But if you want to do it anyway, how about this for a workaround:
code:
git checkout master
git merge --no-commit other-branch
git checkout other-branch . #blow away all differences
git commit

I almost suggested that, actually, but it doesn't handle deletions properly - if master has files A B C, and other-branch adds D and deletes B, those commands may result in you having A B C D rather than A C D, depending on how the initial merge went.

HardDisk posted:

Git works pretty well for text files, as every programmer here that uses it knows, but is there any other VCSs more suitable for other types of files, say images or 3D models?

That's part of why we use Perforce.

There's also git-annex and git-media, neither of which I've used.

good jovi
Dec 11, 2000

'm pro-dickgirl, and I VOTE!

Hughlander posted:

How do you keep that up to date vs github? IE: I'm an engineer I push to github and want to see a build kicked off within seconds. Does kicking off the build start with the slug pulling from github then notifying the 500+ servers?

That's pretty much what we have. A push to github triggers a jenkins job which pulls from github, builds everything, then pushes (SCP, I think) everything out to each server. This relies on having the jenkins server be build identically to the production servers, but that's what puppet is for.

Space Kablooey
May 6, 2009


git-fat seems the more interesting to me. Thanks! :)

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

Hughlander posted:

How do you keep that up to date vs github? IE: I'm an engineer I push to github and want to see a build kicked off within seconds. Does kicking off the build start with the slug pulling from github then notifying the 500+ servers?

We don't do continuous deployment yet, just integration tests. A deploy to all 500+ servers has a bit of process behind it...

Sailor_Spoon posted:

That's pretty much what we have. A push to github triggers a jenkins job which pulls from github, builds everything, then pushes (SCP, I think) everything out to each server. This relies on having the jenkins server be build identically to the production servers, but that's what puppet is for.

Something similar to this. Any new PR (or changes to a PR) triggers a build on Jenkins for our testing platform, and when changes are ready for prod our team merges PRs into a release branch that also triggers a build. We then use an in-house tool to push the slug out to all of our servers (or a single facet, or a single server in each facet, or a percentage of servers, etc...). We plan on releasing the tool at some point to the public, but it's still changing a lot so thats some ways away yet :(

edit: Also, chef is the workhorse. If a new server spins up (EC2 auto scalers) it knows how to fetch the current production slug and install it. Once a server spins up Chef only does a few maintenance tasks (around user access and such).

raminasi
Jan 25, 2005

a last drink with no ice
In git, is there any way to interactively-rebase (for a fixup) back before a merge? Something like:

A
|
B
| \
C  m
|
D

and I want to squash A into C.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
--preserve-merges might work, but it combines oddly with interactive rebases. If the merge is simple, you could just discard it during the rebase then remerge the branch after fixing up C.

raminasi
Jan 25, 2005

a last drink with no ice
I tried that, but there was a merge conflict which confused me because there was no conflict during the original merge, so I just aborted. (The merge wasn't trivial, though.) I've also oversimplified a bit, and the graph should really look like this:

X
|
A
|
B
| \
C  m
|
D

Where A should be squashed into C, but X substantially depends on the merge, so I can't really discard and re-merge. It's not a huge deal, it's just annoying (A is a single line).

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
With the discard-and-re-merge approach you could just discard X as well, then cherry-pick it after re-merging (or if X is actually a bunch of commits that would be annoying to cherry-pick individually, use rebase --onto to transplant the whole series).

Somewhat relevant to this, if you don't have rerere enabled, you should fix that.

Knyteguy
Jul 6, 2005

YES to love
NO to shirts


Toilet Rascal
Is there any good way to do this without spending more time on the architecture of the program?

Basically I want to maintain two separate versions of the same software, but only two of the files are different from eachother between versions. I want all of the other (thousands) of files to stay linked and edited between the two. We use (hosted) TFS if that matters at all.

Thanks.

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb

Knyteguy posted:

Is there any good way to do this without spending more time on the architecture of the program?

Basically I want to maintain two separate versions of the same software, but only two of the files are different from eachother between versions. I want all of the other (thousands) of files to stay linked and edited between the two. We use (hosted) TFS if that matters at all.

Thanks.

Is it some sort of config file or something? Just put them both in the same code base and control which of those two files are used with an environment variable or something.

gariig
Dec 31, 2004
Beaten into submission by my fiance
Pillbug

Knyteguy posted:

Is there any good way to do this without spending more time on the architecture of the program?

Basically I want to maintain two separate versions of the same software, but only two of the files are different from eachother between versions. I want all of the other (thousands) of files to stay linked and edited between the two. We use (hosted) TFS if that matters at all.

Thanks.

There's always a solution but I don't understand your problem. What does the file do? Is it code that needs to be compiled? Is it configuration? Why do you need this one particular file to change when all of the other thousand files remain the same?

If it's a config file Slow Cheetah is the first thing that pops into my head

EDIT: Also beaten

gariig fucked around with this message at 00:52 on Mar 20, 2014

Knyteguy
Jul 6, 2005

YES to love
NO to shirts


Toilet Rascal
Unfortunately it's not a config file or anything; it's two separate versions of a class (controller) in MVC. Basically I've been rolling back changes and compiling when we need one version, and then rolling "back" to the current version when we need the other. The software doesn't have controller methods that can be overridden.

Anyway since it doesn't sound like there's an easy solution to this, I'll probably just throw a new setting flag in the database and change methodology based on that. Thanks for the help.

Adahn the nameless
Jul 12, 2006

Knyteguy posted:

Unfortunately it's not a config file or anything; it's two separate versions of a class (controller) in MVC. Basically I've been rolling back changes and compiling when we need one version, and then rolling "back" to the current version when we need the other. The software doesn't have controller methods that can be overridden.

Anyway since it doesn't sound like there's an easy solution to this, I'll probably just throw a new setting flag in the database and change methodology based on that. Thanks for the help.

Another idea would be to customize the controller factory to return the correct controller implementation under whatever criteria dictate which version to use (that could be a config flag).

wwb
Aug 17, 2004

^^^^ something like that would be a pretty good approach. Could do it internally to the controller as well where you swap out underlying implementations.

Other thing you could do is use #ifdef a bit and have 2 controllers in one file that chooses based on a build environment variable.

ManoliIsFat
Oct 4, 2002

Or go whole hog with some dependency injection.

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb
If I have a feature branch (git) and it comes time to merge it back into master. There was like 50 commits to the feature branch, so when I merge it I --squash it into a single commit to keep things clean. Is that a bad idea? I want to keep the commit log for master nice and clean, but I could see how those 50 commits might be useful down the road if there was a question about why something was done a certain way. Should I just keep the remote branch around there for that purpose?

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

fletcher posted:

If I have a feature branch (git) and it comes time to merge it back into master. There was like 50 commits to the feature branch, so when I merge it I --squash it into a single commit to keep things clean. Is that a bad idea? I want to keep the commit log for master nice and clean, but I could see how those 50 commits might be useful down the road if there was a question about why something was done a certain way. Should I just keep the remote branch around there for that purpose?

It totally depends on your workflow. You could always give a detailed message in your merge commit. I like to rebase my commits into reasonable, logical changes before merging (see: hiding the sausage).

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
Squashing 50 commits into one is almost certainly excessive, unless the whole series of commits is introducing just a single new thing and nearly all of the commits are just fixing bugs in that new thing.

prefect
Sep 11, 2001

No one, Woodhouse.
No one.




Dead Man’s Band

fletcher posted:

If I have a feature branch (git) and it comes time to merge it back into master. There was like 50 commits to the feature branch, so when I merge it I --squash it into a single commit to keep things clean. Is that a bad idea? I want to keep the commit log for master nice and clean, but I could see how those 50 commits might be useful down the road if there was a question about why something was done a certain way. Should I just keep the remote branch around there for that purpose?

Have you pushed your feature branch anywhere? If so, neither squash nor rebase, for those are the tools of the devil.

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb

prefect posted:

Have you pushed your feature branch anywhere? If so, neither squash nor rebase, for those are the tools of the devil.

Yea I've been pushing it to a remote branch at the end of every day.

Most of the commits are just dumb little things and bug fixes for the new feature before it had a round of testing on it. Once testing starts each bug would then be handled in a separate ticket/commit.

ExcessBLarg!
Sep 1, 2001
I don't like the idea of "well, if you want to know the real history, look at the repo over there." But if you have to do a squashed merge (using gerrit or something), it's strictly better to provide a detailed history somewhere with a pointer to it in the commit message, then to eliminate it entirely.

If you don't have to do a squashed merge, then either keep the entire feature history in place, or maybe clean up the most egregious commits. On the master branch, "git log --first-parent" will provide the summarized history you're looking for, while the detailed feature commits are still there for when you need them.

Edit: The problem with squash and rebase isn't whether you're pushing to a remote repository. It's whether anyone else has access to that remote repository and is likely to have cloned/fetched from it.

Adbot
ADBOT LOVES YOU

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb
Thanks for all the comments on my last question, very helpful!

Got another one now. I've been using tags to label versions for release. Last release was 2.5.0 and I'm currently working on 2.6.0, but there's a hotfix that needs to go out before 2.6.0. So I created a new branch off 2.5.0:

code:
$ git checkout -b 2.5.1 2.5.0
Made the appropriate changes and then pushed the branch:

code:
$ git push --set-upstream origin 2.5.1
So two questions: (1) Is this an acceptable way of doing it? (2) How should I incorporate the changes made for 2.5.1 into 2.6.0?

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