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
nielsm
Jun 1, 2009



Ender.uNF posted:

Is there any way to set an ignore file that is committed as part of the repo, but applies to all branches? Right now I have to cherry pick and merge to mine and everyone else's named branches, plus the legit branches, otherwise some of our devs accidentally commit crap.


No, since the .gitignore file is a file, it's part of a tree like any other file and you can't really just silently add anything to a tree. (At least it creates a new commit anyway, per tree/branch.)
What you can perhaps do is write a hook script that validates pushes to the central repository, and reject them if they contain unwanted things.

Adbot
ADBOT LOVES YOU

Edison was a dick
Apr 3, 2010

direct current :roboluv: only

Ender.uNF posted:

Git question... I think the answer is no, but wanted to make sure. We have a bunch of branches going at the same time. Often I find myself needing to make changes to the ignore file as I clean things up (move binary dependencies to a private nuget repo, exclude build products, etc). Is there any way to set an ignore file that is committed as part of the repo, but applies to all branches? Right now I have to cherry pick and merge to mine and everyone else's named branches, plus the legit branches, otherwise some of our devs accidentally commit crap.

Correct. The scopes you can ignore are

  • Per directory and subdirectories in a branch.
    This is the .gitignore file
  • Per cloned repository
    This is via .git/info/exclude it has the same format as .gitignore
  • Per user by the core.excludesfile config option, which specifies a file to read with the same format as .gitignore.

You could do it organisation wide by setting core.excludesfile to a file in a drop-box or mounted network share, but updating all the branches may be easier.

Le0
Mar 18, 2009

Rotten investigator!
Using svn at work. I have my checkout on my network drive for reasons. Our company network is abysmally designed (everything is flat, no sub network etc..) We are only 50 machines but I mean my speed on the network fluctuates wildly and it sucks basically.

I just now got a problem I never saw before and was wondering if any of you knew what was up.

Out of the blue after releasing a document lock I cannot do any svn operations. I get the message sqlite : database image malformed or something like that. I tried to check for consistency of the .svn database and got plenty of errors but sadly could not repair it. Had to re-checkout everything...

Anyone ever experienced something like that?

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe

Le0 posted:

Using svn at work. I have my checkout on my network drive for reasons. Our company network is abysmally designed (everything is flat, no sub network etc..) We are only 50 machines but I mean my speed on the network fluctuates wildly and it sucks basically.

I just now got a problem I never saw before and was wondering if any of you knew what was up.

Out of the blue after releasing a document lock I cannot do any svn operations. I get the message sqlite : database image malformed or something like that. I tried to check for consistency of the .svn database and got plenty of errors but sadly could not repair it. Had to re-checkout everything...

Anyone ever experienced something like that?

This kind of stuff happened to me constantly when working from our remote office with a lovely connection :( Our solution was to move to mercurial but that probably won't help you in your case, although maybe you could use something like git-svn to alleviate that pain?

Simulated
Sep 28, 2001
Lowtax giveth, and Lowtax taketh away.
College Slice
Strange git problem:

A couple of people made various commits, pulling first each time and pushing their changes. Everything was cool. Then another dev, who had not fetched any changes over those two days added one file, did a "Pull" to merge remote with his local, and pushed that out.

His merge, even though it only contains one file according to the history, completely blasted a bunch of changes from everyone else.

If I run "git log <hash>.. -- file path" I only see commits to that file *after* the merge.

If I run "git log <hash>.. --follow -- file path" I see the other people's commits. The file was not renamed or moved in any way.


So it appears that his merge somehow just ignored/dead-ended the other people's commits, but nowhere in the history/log is this evident as a change of any kind. How can the merge commit not show any changes to the file? In the SourceTree or git GUIs, If I checkout latest and do a Log, none of the commits on the group's timeline show up, only the commits prior to the one dev merging and after. If I checkout detached one of those group commits and look at Log, I see all the missing commits but they just dead-end (if I check out the merge commit and do a Log those commits disappear).

Anyone have ideas?


edit: OK on the merge commit if I show all files I can see the ones that had their changes blasted and if I diff against the other merge parent I see the lines being removed. What I can't figure out is what the one dev did to make this happen. He swears he didn't do anything special.

Simulated fucked around with this message at 23:06 on Apr 30, 2014

Hughlander
May 11, 2005

Ender.uNF posted:

Strange git problem:

A couple of people made various commits, pulling first each time and pushing their changes. Everything was cool. Then another dev, who had not fetched any changes over those two days added one file, did a "Pull" to merge remote with his local, and pushed that out.

His merge, even though it only contains one file according to the history, completely blasted a bunch of changes from everyone else.

If I run "git log <hash>.. -- file path" I only see commits to that file *after* the merge.

If I run "git log <hash>.. --follow -- file path" I see the other people's commits. The file was not renamed or moved in any way.


So it appears that his merge somehow just ignored/dead-ended the other people's commits, but nowhere in the history/log is this evident as a change of any kind. How can the merge commit not show any changes to the file? In the SourceTree or git GUIs, If I checkout latest and do a Log, none of the commits on the group's timeline show up, only the commits prior to the one dev merging and after. If I checkout detached one of those group commits and look at Log, I see all the missing commits but they just dead-end (if I check out the merge commit and do a Log those commits disappear).

Anyone have ideas?


edit: OK on the merge commit if I show all files I can see the ones that had their changes blasted and if I diff against the other merge parent I see the lines being removed. What I can't figure out is what the one dev did to make this happen. He swears he didn't do anything special.

git merge origin/master
git checkout --ours .
git add -A .
git commit


Would probably do it.

revmoo
May 25, 2006

#basta
Coming from git to svn it's been a long time and I don't like it.

How would I get a diff of all revisions by a user between a range of two commits? I have two revision numbers and I want to see a full diff of all commits by that user.

Sulla Faex
May 14, 2010

No man ever did me so much good, or enemy so much harm, but I repaid him with ENDLESS SHITPOSTING
I'm using git now to track code I'm working on myself, so the repository has a single user, no other commits but mine to worry about.

It's updating an existing codebase to a newer version of the framework and I tend to commit when I add new files but I don't know how frequently to commit the rest of the time. I test it as I go on a VM so I'm not worried so much about reverting major gently caress-ups, I just want a trackable history of all my modifications in case of a minor omission or whatever.

Do people tend to have rules-of-thumb for this? I've never actually had to look at the revision history or use it for anything, it's more just a safeguard system for now, so I don't have any experience that tells me "oh I wish I'd committed more/less".

Edison was a dick
Apr 3, 2010

direct current :roboluv: only

Sulla-Marius 88 posted:

I'm using git now to track code I'm working on myself, so the repository has a single user, no other commits but mine to worry about.

It's updating an existing codebase to a newer version of the framework and I tend to commit when I add new files but I don't know how frequently to commit the rest of the time. I test it as I go on a VM so I'm not worried so much about reverting major gently caress-ups, I just want a trackable history of all my modifications in case of a minor omission or whatever.

Do people tend to have rules-of-thumb for this? I've never actually had to look at the revision history or use it for anything, it's more just a safeguard system for now, so I don't have any experience that tells me "oh I wish I'd committed more/less".

If you're going for a full development history, it would make sense to have a commit for every time you run the tests, so you can easily see what you changed since you last ran the test, so you can see what change you made may have broken something.

This gets tedious for changes that take a while, as you end up with a long development history, as there's often a lot of back and forth with the changes, so you have a noisy, and generally not very useful history for working out why a change was made, and why it's currently causing something to break.

So before you push your changes to master, you ought to rebase or squash the development history into commits that are
  • Well documented, so they explain in detail why the change is made, so when you come back to it later, you can see why you frobnicate the plinth before swirling it, before after. You'll thank yourself if you include all the useful information that was in your head, and the commit messages for the development branch.
  • Atomic, so the codebase is always left in a working state, so you can later use git bisect to work out when a feature stopped working.
  • Small, so they can be independently comprehended. To do this properly you generally have to have to separate your commits into
    • providing a new module for making the new feature possible, with its tests
    • the commit to make your code use it
    • a commit to remove the bits that are no longer needed.
    Alternatively, you can squash it all into one commit and deal with huge commits that are harder to read.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...
It really does depend upon your style to some extent. Some people commit every 5 minutes, no matter what. Others only commit after a feature is finished. What Edison was a dick suggests is probably a reasonable solution.

Something to remember is that git has the interactive rebase feature, which allows you to go back in time and fix up your commits to pretend that you did everything perfectly the first time. If you haven't tried it yet, I strongly encourage you to; it's one of the killer features of git.

Sulla Faex
May 14, 2010

No man ever did me so much good, or enemy so much harm, but I repaid him with ENDLESS SHITPOSTING
I was really not expecting such a large number of recommended commits. I suppose it works only one way -- it's better to have more commits that you can squash down into fewer, but you can't break one huge commit up into multiple different chunks to identify the differences in each.

Arcsech
Aug 5, 2008
Does anybody have a "git rebase for idiots" guide? I'm probably just overcomplicating it but it seems obtuse and the few times I've tried rebasing I've hosed things up horrendously.

Edison was a dick
Apr 3, 2010

direct current :roboluv: only

Sulla-Marius 88 posted:

I was really not expecting such a large number of recommended commits. I suppose it works only one way -- it's better to have more commits that you can squash down into fewer, but you can't break one huge commit up into multiple different chunks to identify the differences in each.

You can go the other way, with creative use of git reset HEAD^; git add -p; git commit; git add -a; git commit. However it's much more difficult, since you don't have as much context of what each of the individual changes were if you didn't have the commit messages at the time, and you may end up with extra work keeping the codebase in a working state when 1 commit is logically 2, but the first commit doesn't work on its own, without a bit more scaffolding.

Volmarias
Dec 31, 2002

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

Sulla-Marius 88 posted:

I was really not expecting such a large number of recommended commits. I suppose it works only one way -- it's better to have more commits that you can squash down into fewer, but you can't break one huge commit up into multiple different chunks to identify the differences in each.

You absolutely can go the other way. Take a look at the -p argument to git add, git checkout, etc. You can stage changes line by line, and even write a custom patch section if necessary using your git editor.

It's super powerful, and once you "get" it you suddenly have so much more power over your branch.

hirvox
Sep 8, 2009

Arcsech posted:

Does anybody have a "git rebase for idiots" guide? I'm probably just overcomplicating it but it seems obtuse and the few times I've tried rebasing I've hosed things up horrendously.

https://www.atlassian.com/git/tutorial/rewriting-git-history

Have you modified your .gitconfig to use your favourite diff/merge tool and your favourite editor? Rebasing in itself is not complicated; It just tries to reapply the changes to a different point in the commit tree. Because the commits are merged one at a time, fixing conflicts should be easier than during a full merge. But if you don't see clearly what you're doing, it's easy to treat rebasing as black magic. Oh, and don't be afraid to use git rebase --abort if you feel like you've painted yourself into a corner.

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

hirvox posted:

https://www.atlassian.com/git/tutorial/rewriting-git-history

Have you modified your .gitconfig to use your favourite diff/merge tool and your favourite editor? Rebasing in itself is not complicated; It just tries to reapply the changes to a different point in the commit tree. Because the commits are merged one at a time, fixing conflicts should be easier than during a full merge. But if you don't see clearly what you're doing, it's easy to treat rebasing as black magic. Oh, and don't be afraid to use git rebase --abort if you feel like you've painted yourself into a corner.

For someone who hasn't done a rebase before the concept can be a little strange. I like the verbage they use when you start: "First, rewinding head to replay your work on top of it...". Tells you exactly what rebase does.

evensevenone
May 12, 2001
Glass is a solid.
What I do is frequently amend the commit I'm working on (ie. after almost every save), then create a new commit whenever I hit a breaking point.

That way work is almost always checked in, but the history doesn't get totally huge (and everything but the most recent commit has the codebase in a working state).

If I need to do something more major that's going to keep things broken for a while I'll start a branch, then rebase it on master and possibly squash it down when it's done.

My goal is to always have every commit on master to be working (as far as I know at the time), that makes it easy to select release versions.


necrotic posted:

For someone who hasn't done a rebase before the concept can be a little strange. I like the verbage they use when you start: "First, rewinding head to replay your work on top of it...". Tells you exactly what rebase does.

You can think of it as checking out the base, then cherry-picking each commit in the branch in chronological order, pausing if there are conflicts and asking you to fix them up before continuing.

evensevenone fucked around with this message at 20:18 on May 7, 2014

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

evensevenone posted:

What I do is frequently amend the commit I'm working on (ie. after almost every save), then create a new commit whenever I hit a breaking point.
I almost never amend due to that I failed to figure out a way to get it to not ask me to edit the commit message each time, so making a new commit after every save and then squashing them later involves less disruption while working on things.

evensevenone posted:

My goal is to always have every commit on master to be working (as far as I know at the time), that makes it easy to select release versions.
It also makes git-bisect a million times more useful when every commit builds and works.

Volmarias
Dec 31, 2002

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

evensevenone posted:

What I do is frequently amend the commit I'm working on (ie. after almost every save), then create a new commit whenever I hit a breaking point.

That way work is almost always checked in, but the history doesn't get totally huge (and everything but the most recent commit has the codebase in a working state).

I typically do the opposite; I'll commit relatively frequently (as soon as I've done something worth saving, or even a 30 minute "checkpoint!" commit). I'll amend for "whoops, forgot a letter in a comment" but that's about it. Later, I'll go back and rebase my commits into something more coherent.

Scaevolus
Apr 16, 2007

Plorkyeran posted:

I almost never amend due to that I failed to figure out a way to get it to not ask me to edit the commit message each time, so making a new commit after every save and then squashing them later involves less disruption while working on things.

code:
git commit --amend --no-edit

Axiem
Oct 19, 2005

I want to leave my mind blank, but I'm terrified of what will happen if I do
I really don't get the obsession people have, especially in the git community, for a "clean" history. Personally, I'm content having all my intermediate changes on there; it makes it easier if I go back to follow my own thought process.

Less Fat Luke
May 23, 2003

Exciting Lemon

Axiem posted:

I really don't get the obsession people have, especially in the git community, for a "clean" history. Personally, I'm content having all my intermediate changes on there; it makes it easier if I go back to follow my own thought process.
It makes it a lot easier for going through the history of a project and figuring out via changes why things changed and how. It also makes code easier to review if it's broken up into logical checkpoints. I don't think either are absolutely necessary, but when you jump into a new repo that has a decent rebase policy it seems easier to see its evolution.

o.m. 94
Nov 23, 2009

Axiem posted:

I really don't get the obsession people have, especially in the git community, for a "clean" history. Personally, I'm content having all my intermediate changes on there; it makes it easier if I go back to follow my own thought process.

The operative term being 'your own thought process'. Other people can't or don't always have the time to decipher the last 7 hours of work you just did when everyone has a completely different approach. When you increase the number of developers, housekeeping goes a long way to being able to understand what is going on.

shrughes
Oct 11, 2008

(call/cc call/cc)
What I don't get is how people don't manage to have a fine-grained history comprised of logical checkpoints. Sometimes you need to make a big change, but, usually?

raminasi
Jan 25, 2005

a last drink with no ice

Axiem posted:

I really don't get the obsession people have, especially in the git community, for a "clean" history. Personally, I'm content having all my intermediate changes on there; it makes it easier if I go back to follow my own thought process.

"fix typo in comment"

shrughes posted:

What I don't get is how people don't manage to have a fine-grained history comprised of logical checkpoints. Sometimes you need to make a big change, but, usually?

"Fine-grained" is hardly an objective term.

aerique
Jul 16, 2008

GrumpyDoctor posted:

"fix typo in comment"

Then again it avoids regressing the typo back into your software when reverting a big commit and looking stupid to your users.

raminasi
Jan 25, 2005

a last drink with no ice
No history clean-freaks edit published history. (None I'd want to be associated with, anyway.)

Steve French
Sep 8, 2003

aerique posted:

Then again it avoids regressing the typo back into your software when reverting a big commit and looking stupid to your users.

All those users reading comments in your code, yeah

Deus Rex
Mar 5, 2005

revmoo posted:

Coming from git to svn it's been a long time and I don't like it.

How would I get a diff of all revisions by a user between a range of two commits? I have two revision numbers and I want to see a full diff of all commits by that user.

git log --author="a regex that partially matches the author field" dead..beef It's in the manpage for git-log or at git log --help.

Steve French posted:

All those users reading comments in your code, yeah

for certain products where users are developers that have a license to your source, yeah (not that a simple typo is necessarily going to make you look bad to them)

Deus Rex fucked around with this message at 20:28 on May 8, 2014

Axiem
Oct 19, 2005

I want to leave my mind blank, but I'm terrified of what will happen if I do

o.m. 94 posted:

The operative term being 'your own thought process'. Other people can't or don't always have the time to decipher the last 7 hours of work you just did when everyone has a completely different approach. When you increase the number of developers, housekeeping goes a long way to being able to understand what is going on.

I guess it also depends on the context and the culture of a development group.

At home, it's just me, and I really don't care, because I see version control more as a way of keeping a backup and the ability to easily reverse huge changes if I go down the rabbit hole, along with making deployment easier.

At work, I'm on a small team, and we have a very much commit-and-push mentality, with the rule being that each commit should be just big enough to make a change to make the app better without breaking it. So we have a very long master, but in theory, we never have a state where the app is unusable.

aerique
Jul 16, 2008

Steve French posted:

All those users reading comments in your code, yeah

Yeah, I guess I should have read that better.

lord funk
Feb 16, 2004

Nothing fancy, but I like saying this line out loud:

Objective-C code:
AVPlayerLayer *playerLayer = [AVPlayerLayer playerLayerWithPlayer:player];
edit: well that has nothing to do with version control (wrong thread)

lord funk fucked around with this message at 19:51 on May 9, 2014

raminasi
Jan 25, 2005

a last drink with no ice
This might be more of a Visual Studio question, but does anyone have any idea why the Git Extensions source control provider isn't showing up as available in VS 2013? (I know there's built-in git, but it doesn't seem as fully-featured as the one I've been used to.) I can see that the add-in is loaded, but it's not in the source control plug-in list.

Thel
Apr 28, 2010

So say I approved a pull request into a github repo and now I want to break the developers' heartsunapprove their pull request and force them to architect their poo poo properly, how hard is that?

(If it helps - gitflow, and it was a merge into a feature branch from a dev's fork. There's been no further merges or commits into that branch as yet.)

The Laplace Demon
Jul 23, 2009

"Oh dear! Oh dear! Heisenberg is a douche!"

Thel posted:

So say I approved a pull request into a github repo and now I want to break the developers' heartsunapprove their pull request and force them to architect their poo poo properly, how hard is that?

(If it helps - gitflow, and it was a merge into a feature branch from a dev's fork. There's been no further merges or commits into that branch as yet.)

Use git log to get the hash of the commit before the bad merge, git reset --hard <hash> back to it, then git push -f origin <branch name>, assuming the github repo is origin. Then send them an email or whatever telling them to reopen their pull request.

If it was the very last thing, you could also do git reset --hard HEAD~1.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

The GitHub help page for creating a project page says:

quote:

To set up a Project Pages site, you need to create a new "orphan" branch (a branch that has no common history with an existing branch) in your repository. The safest way to do this is to start with a fresh clone:

Umm, what's unsafe about just creating the required orphan branch without creating a fresh clone?

Can't I just do the next step on that page and skip the clone part?

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
If you sufficiently mistype "git rm -rf ." you could delete things you don't want to delete, which is far less of a danger if you're working in a fresh clone.

Deus Rex
Mar 5, 2005

Thel posted:

(If it helps - gitflow, and it was a merge into a feature branch from a dev's fork. There's been no further merges or commits into that branch as yet.)

I'll note that since it's a feature branch it's probably okay to do do a hard reset and force push. But it could be a pain to clones downstream from you that are tracking that branch.

Another safer (but noisier) option is to revert the merge. This is what you'd probably want to do had you merged this pull request into your main or master branch (which likely have many trackers). http://git-scm.com/blog/2010/03/02/undoing-merges.html

Harik
Sep 9, 2001

From the hard streets of Moscow
First dog to touch the stars


Plaster Town Cop
I'm managing an android release (Not an app, a full android build) and I'm trying to improve the build versioning management. It works out to ~350mb of binaries. I don't think git-annex is a good fit due to the symlinks - I need the actual files in place so the release can make a filesystem image. I can't just follow symlinks, since some symlinks need to be part of the filesystem.

The main reason I'd like a git-like is to handle three-way-merges better. If we field-fix a unit that's behind mainline, with git I can rsync its filesystem on top of a checkout of the matching release, commit the just the changes for the issue in question, then rebase that to mainline. This is a common workflow, since the devices in the field are in beta stage and we've got remote SSH access into them to edit/replace files on the fly.

I'm asking because I feel like I'm holding a hammer and thinking this is a nail. Is there a better tool for the job?

Adbot
ADBOT LOVES YOU

Edison was a dick
Apr 3, 2010

direct current :roboluv: only

Harik posted:

I'm managing an android release (Not an app, a full android build) and I'm trying to improve the build versioning management. It works out to ~350mb of binaries. I don't think git-annex is a good fit due to the symlinks - I need the actual files in place so the release can make a filesystem image. I can't just follow symlinks, since some symlinks need to be part of the filesystem.

Git Annex has a mode to not replace git annex added files with symlinks in the working tree. Git-Fat would also work, but it requires a centralised rsync repository, so may not be a good fit for every organisation.

quote:

The main reason I'd like a git-like is to handle three-way-merges better. If we field-fix a unit that's behind mainline, with git I can rsync its filesystem on top of a checkout of the matching release, commit the just the changes for the issue in question, then rebase that to mainline. This is a common workflow, since the devices in the field are in beta stage and we've got remote SSH access into them to edit/replace files on the fly.

I'm asking because I feel like I'm holding a hammer and thinking this is a nail. Is there a better tool for the job?

It's definitely not something Git is designed for. I've read articles by people from Atlassian who were saying we needed to get better at version controlling our output, hence we need to buy their product, which felt too much like marketing for me to be interested.

At work we're working on tools for embedded development, where we're trying to solve this problem by ensuring we don't ever need to check in the result of a build, by making builds fast and always reproducible. We don't yet do Android though, and to tell the truth, we're not there yet for actually applying updates reliably.

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