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
Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
I finally came to appreciate the git merge versus rebase debate the other day. I normally only do anything at all interesting with team projects outside of work, so I was used to just merging. Now I have somebody telling me their work team's policy has been using rebase to join branches back to the master. I looked it up and I'm flabbergasted. That's a lot of history alteration and undoing it is a real pain in the rear end. I had assumed when they originally told me they rebased that they were using it to collapse multiple commits before making a merge, or maybe they were rebasing to incorporate master into their branch. But really... rebasing your branch onto the master?

Adbot
ADBOT LOVES YOU

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

uXs posted:

Is there some way in Git to just checkout the latest commit, skipping over all the intermediate ones?

I had some coworkers commit things with paths beyond the maximum Windows path length, and now I can't get to the latest version, which doesn't have those files anymore.

A shallow-clone should pull only the latest commit, but eventually I think you need the rest of the history? I haven't really looked into shallow clones.

nielsm
Jun 1, 2009



uXs posted:

Is there some way in Git to just checkout the latest commit, skipping over all the intermediate ones?

I had some coworkers commit things with paths beyond the maximum Windows path length, and now I can't get to the latest version, which doesn't have those files anymore.

Is the problem that your current working copy (on Windows) has files with too long paths, which then can't be removed?

If that's the case, you will probably have to remove them manually. The easiest way, that doesn't need special software, is usually to rename folders above the "victim" files until the total paths are sufficiently short.
You may have to do some hard resetting or other nasty stuff after that, to get your working copy working again.

Ralith
Jan 12, 2011

I see a ship in the harbor
I can and shall obey
But if it wasn't for your misfortune
I'd be a heavenly person today

22 Eargesplitten posted:

I made a pretty embarrassing typo in one of my commit messages. I've updated a lot of the contents, but stuff like the project file and other basic stuff that doesn't get changed still has it. Basically I started trying to write a commit message within my commit message when I had just started out with .git. I want to use this project as part of my portfolio, so I want to make it look nice. Or, since I also cleaned up a really messy file system, would it look most professional to just delete that repo and push the finished project to a new one?
For a personal project, i.e. one nobody else has ever cloned, just go back and edit the commit message with an interactive rebase.

22 Eargesplitten
Oct 10, 2010



I've been running into problems a lot where I don't like the changes I made and I want to get rid of them and pull the last commit I had. What's the best way to do that? I just got a bunch of weird merge errors when I tried git reset --hard and then git pull origin master. Now the script I was wanting to work on has gibberish all over the place.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

22 Eargesplitten posted:

I've been running into problems a lot where I don't like the changes I made and I want to get rid of them and pull the last commit I had. What's the best way to do that? I just got a bunch of weird merge errors when I tried git reset --hard and then git pull origin master. Now the script I was wanting to work on has gibberish all over the place.

git reset <commit id you want to go back to> --hard

Or to just go back to the place you were when you last pushed to origin:
git reset origin/branchname --hard

22 Eargesplitten
Oct 10, 2010



Okay, that's what I did, I'm not sure why it screwed up like that.

Zoracle Zed
Jul 10, 2001
If you're looking at a gitbhub PR, and you have a non-trivial suggestion to make, or an alternative implementation, how do you relay that? Make a PR to the submitter's fork? Or submit a new PR to the original repo, on top of their PR?

the talent deficit
Dec 20, 2003

self-deprecation is a very british trait, and problems can arise when the british attempt to do so with a foreign culture





if it's an alternative implementation i'd only bother if it's objectively much better and i'd do it as it's own pr. otherwise i'd just comment on the pr or move along

tak
Jan 31, 2003

lol demowned
Grimey Drawer
Fork the repo, checkout the PR's branch, make your change, commit, push, then link the diff on github in the PR comments

e.g.
code:
https://github.com/THEIR_USER/REPO/compare/THEIR_USER:THEIR_PR_BRANCH...YOUR_USER:YOUR_BRANCH

22 Eargesplitten
Oct 10, 2010



I feel like there should be an obvious answer to this question, but googling isn't finding it. Is there some sort of setting for github to let people download a repo without my needing to approve it? Or does it do that automatically? I just see that it's called a pull request, which sounds like I need to approve it.

nielsm
Jun 1, 2009



22 Eargesplitten posted:

I feel like there should be an obvious answer to this question, but googling isn't finding it. Is there some sort of setting for github to let people download a repo without my needing to approve it? Or does it do that automatically? I just see that it's called a pull request, which sounds like I need to approve it.

A pull request is someone asking you to integrate a change of theirs. (Requesting you to pull a change from them.) If your repository is public, anyone can clone it, i.e. make a copy for themselves.

22 Eargesplitten
Oct 10, 2010



Oh, okay. I always think of pulls as being from the repo rather than to the repo. That makes more sense. Cool, I just wanted to make sure I wasn't linking to my github on my resume and then giving potential employers no way to actually get my code.

Thermopyle
Jul 1, 2003

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

22 Eargesplitten posted:

Oh, okay. I always think of pulls as being from the repo rather than to the repo. That makes more sense. Cool, I just wanted to make sure I wasn't linking to my github on my resume and then giving potential employers no way to actually get my code.

Thunk of it like this: they are Requesting that you Pull their changes into your repo.

raminasi
Jan 25, 2005

a last drink with no ice
I just pushed to github, and git status reports that my local branch is up-to-date with the remote, but the push isn't reflected on Github. It's like it never happened. Any ideas?

good jovi
Dec 11, 2000

'm pro-dickgirl, and I VOTE!

raminasi posted:

I just pushed to github, and git status reports that my local branch is up-to-date with the remote, but the push isn't reflected on Github. It's like it never happened. Any ideas?

Github appears to be having some issues at the moment.

revmoo
May 25, 2006

#basta

good jovi posted:

Github appears to be having some issues at the moment.

lmao, but that never happens

Taliesin
Aug 15, 2002

Shake it Baby!
If only they had a way to roll back to a more stable version.

Ciaphas
Nov 20, 2005

> BEWARE, COWARD :ovr:


In Git, say I were to push one of my branches up to origin for others in my team to look at, via git push origin ovm_optimize. When they're done looking at it, should I then delete it on origin via git push origin :ovm_optimize, or does it really not matter at all/depends on my team policy (which I'm pretty much making up as I go along anyway)?

For that matter, is there a nicer way to delete a remote branch than that? I understand what it means and why it works, it just looks doofy :v: (ed: I guess I could write an alias, huh)

Stringent
Dec 22, 2004


image text goes here

Ciaphas posted:

In Git, say I were to push one of my branches up to origin for others in my team to look at, via git push origin ovm_optimize. When they're done looking at it, should I then delete it on origin via git push origin :ovm_optimize, or does it really not matter at all/depends on my team policy (which I'm pretty much making up as I go along anyway)?

For that matter, is there a nicer way to delete a remote branch than that? I understand what it means and why it works, it just looks doofy :v: (ed: I guess I could write an alias, huh)

I'm not familiar with that colon syntax, what is it?

The manual just says to do this:
code:
git push origin --delete ova_optimize

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Stringent posted:

I'm not familiar with that colon syntax, what is it?

The manual just says to do this:
code:
git push origin --delete ova_optimize


[edit]
I was wrong! It's actually way more complicated than that!

http://stackoverflow.com/questions/7303687/why-git-use-the-colon-branch-to-delete-remote-branch

Ciaphas
Nov 20, 2005

> BEWARE, COWARD :ovr:


Stringent posted:

I'm not familiar with that colon syntax, what is it?

The manual just says to do this:
code:
git push origin --delete ova_optimize

It's what I was taught from the git book--read as "take nothing and overwrite the remote's branch called ovm_optimize with it". Like I said, kinda doofy!

Guess they must have added --delete in a later revision.

RICHUNCLEPENNYBAGS
Dec 21, 2010
--delete was added in version 1.7.0.

https://github.com/gitster/git/blob/master/Documentation/RelNotes/1.7.0.txt

Ciaphas
Nov 20, 2005

> BEWARE, COWARD :ovr:


We've got updated books at work now and, yeah, they both mention the colon delete syntax as historical footnotes. The one I was referencing appears to have been written with 1.6.1 in mind.

Still kinda wracking my brain on what sort of policy to set with our team re: pushing and deleting topic branches to central: whether to push them at all, whether to delete them, whether to rebase onto master and fast forward when done or always merge with --no-ff, etc. Being the CM guy is hard even on a small team of four :saddowns:

Stringent
Dec 22, 2004


image text goes here

Ciaphas posted:

We've got updated books at work now and, yeah, they both mention the colon delete syntax as historical footnotes. The one I was referencing appears to have been written with 1.6.1 in mind.

Still kinda wracking my brain on what sort of policy to set with our team re: pushing and deleting topic branches to central: whether to push them at all, whether to delete them, whether to rebase onto master and fast forward when done or always merge with --no-ff, etc. Being the CM guy is hard even on a small team of four :saddowns:

We push feature branches to remote. Make a pull request to the target branch. That gets merged into the target branch, ff if possible optionally --squash if you want to do all your merge conflicts in one go. Then the remote feature branch is deleted.

Gounads
Mar 13, 2013

Where am I?
How did I get here?

Stringent posted:

We push feature branches to remote. Make a pull request to the target branch. That gets merged into the target branch, ff if possible optionally --squash if you want to do all your merge conflicts in one go. Then the remote feature branch is deleted.

The nice thing if you're using github, is there is a "Delete branch" button after you press the merge button.

Also, for your local sanity, add to your .gitconfig:

[alias]
cleanfeature = branch --merged | grep "feature/" | xargs -n 1 git branch -d


Then, run "git cleanfeature" from your development branch, and it will delete all local branches that start with "feature/" and have been fully merged.

Hughlander
May 11, 2005

Ciaphas posted:


Still kinda wracking my brain on what sort of policy to set with our team re: pushing and deleting topic branches to central: whether to push them at all, whether to delete them, whether to rebase onto master and fast forward when done or always merge with --no-ff, etc. Being the CM guy is hard even on a small team of four :saddowns:

We have a script that deletes merged branches with the last commit greater than 30 days ago and sends an email if it's not merged but last commit of 60 days ago unless that commit also has a note to not send mail.

ExcessBLarg!
Sep 1, 2001

Ciaphas posted:

Still kinda wracking my brain on what sort of policy to set with our team re: pushing and deleting topic branches to central: whether to push them at all, whether to delete them, whether to rebase onto master and fast forward when done or always merge with --no-ff, etc.
You want to encourage folks to push branches somewhere or else they'll get lost. If you're OK with a little clutter in the main repository then I recommend pushing feature or "private" WIP branches there (the latter being prefixed by an owning username which allows them by policy to force-push on that branch as they please) and encourage deletion once the branches are done. Another alternative is to fork "private" repositories and encourage folks to push WIP branches to those, but then it's harder to track down someone's WIP if you need to.

As for merge vs. rebase, I really believe there's no one right policy. Any change that's one commit in size (possibly because it's been squashed) should probably be rebased so you don't burn a merge commit and there's no real downside. But if there's been work done on a feature branch for a while, where the historical context is important, then a merge is definitely appropriate. For things in the middle, it's more of a question of whether individual commits on a feature branch actually communicate anything, and if they don't then squash them.

For some people it's important to track each branch merge explicitly in which you probably never want to rebase, but I don't think that has any inherent value.

Ciaphas
Nov 20, 2005

> BEWARE, COWARD :ovr:


I lean toward rebasing, personally, but the boss of my team is a little squirmy on the idea of :airquote: losing history in that manner. Part of the clearcase background, I guess, where history is nearly immutable (and branches are totally different concepts, eugh).

ExcessBLarg!
Sep 1, 2001
There's situations in which rebasing is a measurably worse. Rebasing a stack of commits that have regular merge conflicts with the main branch is very painful to churn through. There's also a good chance that the nature of the conflicts renders the interim commits broken or moot--certainly you're not testing each individual commit as you churn through the rebase. It's much better to do either a regular merge and resolve the conflicts at once, or a squash and rebase which is effectively the same but results in a simpler history.

On the other hand, rebasing a small number of conflict-free commits is just as easy as a merge and results in a linear history as well. If the rebased changes are really orthogonal to whatever development was going on the main branch there's no downside.

My point is that it's very much situation dependent, and "always merge" or "always rebase" policies don't take into account the specifics of any particular situation for which one approach may well be superior to the other.

Plorkyeran
Mar 22, 2007

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

ExcessBLarg! posted:

There's situations in which rebasing is a measurably worse. Rebasing a stack of commits that have regular merge conflicts with the main branch is very painful to churn through. There's also a good chance that the nature of the conflicts renders the interim commits broken or moot--certainly you're not testing each individual commit as you churn through the rebase.
You should be. I always build and run all tests on each commit which had conflicts, and if I suspect any of the intermediate commits which didn't have conflicts may have been broken I'll run the tests on those as well. This takes a bunch of CPU time but very little human time.

Ciaphas
Nov 20, 2005

> BEWARE, COWARD :ovr:


I do compile checks at most when a git conflict crops up, but that's mostly because in our shop and the way our databases are structured going back to past versions of the software is a bit of a fool's errand anyway.

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb
Got a question about working with a large team. Let's say the team is big enough such that somebody is pushing code every 10 minutes. If it takes 40 minutes to compile & run tests, it seems impossible to compile & run tests before you push your code. I mean you can do it with a fairly recent commit to be reasonable sure it will work when the build server picks up your changes.

I'm wondering, what are some ways to improve this situation? It seems like maybe splitting up the single huge repo into multiple smaller ones would help a bit.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

fletcher posted:

Got a question about working with a large team. Let's say the team is big enough such that somebody is pushing code every 10 minutes. If it takes 40 minutes to compile & run tests, it seems impossible to compile & run tests before you push your code. I mean you can do it with a fairly recent commit to be reasonable sure it will work when the build server picks up your changes.

I'm wondering, what are some ways to improve this situation? It seems like maybe splitting up the single huge repo into multiple smaller ones would help a bit.

40 minutes on a developer machine? How long of that is spent building versus running tests? Are the tests integration tests, unit tests, functional tests, etc?

A few ways to address this kind of thing, off the top of my head:
- If the application itself takes a long time to build, either switch to a microservice architecture with versioned APIs or start using a package manager so you can build and test only what's changing instead of the whole application.
- If the tests take a long time to run, look at the tests.
Unit tests: Make sure they're actually unit tests (by which I mean everything that's not the code under test is being mocked). Make sure that each test case actually tests a unique, valid scenario. I've seen plenty of times where someone wrote 15 tests of which 14 are testing the same thing. If an individual test takes under 5-10 milliseconds to run it's probably not worth worrying about, unless you have thousands of tests.
Are they integration tests? Make sure they shouldn't be unit tests, but someone was being lazy and didn't feel like mocking the data access layer, or something like that.
Are they functional tests (like a UI test)? Don't run those so frequently, those work best as smoke tests as a post-deployment step before the QA team gets their hands on it.

Then you can do actual CI against the pieces of the application as they change, and do a big "everything and the kitchen sink" build/test run as frequently as makes sense for the size of the codebase (every hour? two hours? Twice a day?)

Hughlander
May 11, 2005

fletcher posted:

Got a question about working with a large team. Let's say the team is big enough such that somebody is pushing code every 10 minutes. If it takes 40 minutes to compile & run tests, it seems impossible to compile & run tests before you push your code. I mean you can do it with a fairly recent commit to be reasonable sure it will work when the build server picks up your changes.

I'm wondering, what are some ways to improve this situation? It seems like maybe splitting up the single huge repo into multiple smaller ones would help a bit.

What we've done is parallelize the tests and minimize the chance of failures, then run them in a queued fashion first in first tested. It can still be hour+ before your change is on master if 4-5 people push at the same time.

Ralith
Jan 12, 2011

I see a ship in the harbor
I can and shall obey
But if it wasn't for your misfortune
I'd be a heavenly person today

fletcher posted:

Got a question about working with a large team. Let's say the team is big enough such that somebody is pushing code every 10 minutes. If it takes 40 minutes to compile & run tests, it seems impossible to compile & run tests before you push your code. I mean you can do it with a fairly recent commit to be reasonable sure it will work when the build server picks up your changes.

I'm wondering, what are some ways to improve this situation? It seems like maybe splitting up the single huge repo into multiple smaller ones would help a bit.

Would it make sense to get people to switch to committing larger units of work? Normally you'd have people working in a private branch for a while, and only run a full test suite and merge to master once their feature or fix or whatever is complete and reviewed.

You also want a pool of machines to parallelize test runs, of course.

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb
Yup we're running tests in parallel, and folks are working on private branches and then merging in larger chunks of changes when they are ready. Thanks for the other suggestions as well, I will explore those further.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Ithaqua posted:

I have a client who is currently using centralized VC (and they're not switching; they would be miserable using Git). However, they have literally 20 GB of images in their application, mixed in liberally among the code. They have a weird content deploy process in place, but it doesn't synchronize across all their enviroments, only production. And it's flaky enough that it's okay, but every build they do that's going to eventually make it to prod has to include all the content, which means they have tons of 20 GB build artifacts clogging up their servers, when 19.8 of the 20 GB is exactly the same and static between every single build they've done.

They want to start having content deploy to all environments, and going through a "download from VC, 'build' it by copying to an artifact drop location, then copy to the target server" process is a huge waste of space and effort... not to mention the hoops the developers have to jump through to deal with not syncing up gigs of irrelevant crap.

So, my thought was to split the content out into a Git-LFS repo. The folks working on content can commit and push their changes, and the sites can just clone the repo into the appropriate folder. Put a .gitignore file in place for non-content files, they merge from dev -> qa via a PR, an automated process fires that does git clean (to remove deleted and now-untracked files) and git pull on the QA servers. And so on and so forth. Even if cloning the repos directly in the live, running application isn't a great idea, it would be trivial to clone the repo into a directory on the build box and do an incremental sync from the appropriate branch to the appropriate environment.

They still can't explain why they can't use a CDN for this, of course.

Does anyone have any thoughts on this, or am I being a crazy person?

[edit]
One other wrinkle I just thought of: They have some content that's "baseline" and some content that's region-specific, since they're multinational and have different versions of their software for US, Canada, various EU countries, UK, etc. All built from the same codebase with different libraries and page templates substituted in, with all the content for specific countries/languages separated into folders like "fr-ca" and "en-us", etc.

I'd need to solve the "each region has a different set of content but content people need to see it all as a single unit because that's how they're used to it working" problem. Sounds like a case for submodules.

...and another wrinkle: sometimes the "baseline" content changes, but not for all the regions at once, since the regions are all on different versions and released on different schedules. And this needs to be relatively easy to manage because the people working on content aren't developers, so trying to explain Git to them in the first place will be a challenge, let alone cracking open the Pandora's box of submodules.

Anyone have any thoughts on this? I just got a panicked call from this client because their content deployment process mysteriously deleted a bunch of files from production and I'm going to spend the next day or two trying to reproduce the issue so we can figure out what the hell happened.

Hughlander
May 11, 2005

Ithaqua posted:

Anyone have any thoughts on this? I just got a panicked call from this client because their content deployment process mysteriously deleted a bunch of files from production and I'm going to spend the next day or two trying to reproduce the issue so we can figure out what the hell happened.

git-lfs works well but if they won't use that you can do something vaguely similar with a roll your own that I've used before git-lfs was a thing:

Check in a manifest file, containing a list of files and their SHA for the current version.
Store each file by SHA in Amazon S3.
Have a small script that reads the manifest file and downloads each file that doesn't exist to a permanent storage location. (By SHA)
Have a second or same script to hard-link the file in it's final path/name from the SHA.

Bonus: rolling back content is instantaneous as you just need to relink it.

Adbot
ADBOT LOVES YOU

pliable
Sep 26, 2003

this is what u get for "180 x 180 avatars"

this is what u fucking get u bithc
Fun Shoe
I'm having some weird permissions issue when trying to load an SVN dump file on my local machine. I'm on Windows 7.

I received an SVN dump file from a vendor of ours, and I'm trying to load it to verify that it's a valid dump file. https://blog.codinghorror.com/setting-up-subversion-on-windows/ - I used this guide to set up an SVN server as a service on my local machine. The service seems to be running fine, and I can checkout/commit as well. I've also set up the service to Log On as myself, where I am a local administrator on my machine. Now, I'm trying to run this command from an Administrator shell:

code:
C:\myproject>svnadmin load C:\myproject < C:\dumpfile
Seems like it should be easy enough, but then I get this error:

code:
svnadmin: E720005: Can't open file 'C:\myproject\format' : Access is denied.
Okay, fine. For one it seems to want a "format" folder, so I created that. As for the permissions:



Every group or user name has Full Control permissions. The folder myproject\format also has the same exact permissions. I've scoured Google for the past 6 hours with no results. I know Windows permissions are a weird beast compared to Unix permissions, but I'm stumped at this point. What the gently caress am I missing? Thank you much for any and all help!

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