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
ChickenWing
Jul 22, 2010

:v:

Stringent posted:

Yeah, but in the future that's how you should handle this, imo.

Even before I fixed things, I'd think that's what would have happened.

code:
A-------M1----M1'-----M2
B-C-D--/-------------/
When you try and do M2, it'll say no changes because after M1' the branch looks like

code:
A-B-C-D-M1-M1'
And so when you do M2, BCD are already in the history and git thinks there's nothing to merge

Adbot
ADBOT LOVES YOU

Infected Mushroom
Nov 4, 2009
Not sure if there’s a better way but you can revert a revert and then it will let you remerge the branch

smackfu
Jun 7, 2004

Is there a git one-liner to rebase and squash all the outstanding commits? Currently I do an interactive rebase and then mark all the lines except the first as squash or fixup, but that is a bit tedious.

necrotic
Aug 2, 2005
I owe my brother big time for this!
You can put certain content in your commit messages to affect an auto-rebase: https://robots.thoughtbot.com/autosquashing-git-commits

smackfu
Jun 7, 2004

Cool, didn’t know about that.

So in theory instead of:

git commit -m wip

I can do something like:

git commit —fixup head

And then the squash rebase will be automatic, eventually.

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

smackfu posted:

Is there a git one-liner to rebase and squash all the outstanding commits? Currently I do an interactive rebase and then mark all the lines except the first as squash or fixup, but that is a bit tedious.

There's git merge --squash for the simple case. I haven't used autosquash before but it looks pretty awesome for more complex workflows.

Thermopyle
Jul 1, 2003

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

Are there any services that will automatically mirror a not-hosted-at-github repo to a hosted-at-github repo?

The Fool
Oct 16, 2003


Thermopyle posted:

Are there any services that will automatically mirror a not-hosted-at-github repo to a hosted-at-github repo?

Wouldn’t most CI services do this? I only have experience with the CI components of VSTS, and can definitely do it with the tools built in there.

I’ve heard good things about https://concourse-ci.org/

FE: I could mirror a non-vsts git repository to github with VSTS using the built in tools.

Thermopyle
Jul 1, 2003

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

The Fool posted:

Wouldn’t most CI services do this? I only have experience with the CI components of VSTS, and can definitely do it with the tools built in there.

I’ve heard good things about https://concourse-ci.org/

FE: I could mirror a non-vsts git repository to github with VSTS using the built in tools.

To be clear, the not-hosted-on-github repo is not mine nor do I have any sort of control to it. I'm trying to avoid the source repo disappearing because the main dev gets pissy or whatever.

I was just hoping there was some simple dedicated service out there where I could enter the url to the source repo and a destination repo credentials or whatever and it'd do the work of periodically checking for new commits on the source repo and pulling them and then pushing them to the destination.

hailthefish
Oct 24, 2010

Tried something like https://github.com/new/import ?

It won't automatically update with changes from the original source after you import, but for forking someone else's project as a safetynet for rage-deletes it should work?

Data Graham
Dec 28, 2009

📈📊🍪😋



Set multiple remotes, and alias “git push” to a pair of commands that pushes to both remotes?

boo_radley
Dec 30, 2005

Politeness costs nothing

Data Graham posted:

Set multiple remotes, and alias “git push” to a pair of commands that pushes to both remotes?

I was going to suggest something similar. Not sure you'd find a service to sync repos like you're describing. Importing, yes, but synchronizing is different.

The Fool
Oct 16, 2003


In VSTS, and I assume other hosted CI solutions you can setup a build pipeline on a schedule that can pull from the repo in question and then push it to github.

Sedro
Dec 31, 2008
I just finished a difficult merge... but now there are new commits to both branches. What's the best way to bring it up to date?

tak
Jan 31, 2003

lol demowned
Grimey Drawer

Sedro posted:

I just finished a difficult merge... but now there are new commits to both branches. What's the best way to bring it up to date?

Pull the new commits on the branch you merged into, then merge the other branch again:

code:

git pull
git merge the-other-branch

Linear Zoetrope
Nov 28, 2011

A hero must cook

tak posted:

Pull the new commits on the branch you merged into, then merge the other branch again:

code:
git pull
git merge the-other-branch

You may need to do `git merge origin/the-other-branch` because pull will only merge upstream changes into the branch you're currently on.

bollig
Apr 7, 2006

Never Forget.
Hello everyone this is going to be a longish post, I'm kind of a noobie at git/github and I thought I knew more than I did. I've started a new remote job and the project I'm working on has like one overarching project and then some subprojects so the folder structure is sort of like this:

code:
Big_project/
     sub_project/folder/shit_im_working_on.py
So to get started, I cloned Big_project and then cloned sub_project into its corresponding folder. However when I git init'd, I did it in the Big_project folder and its origin url is the Big_project repo.

I created a branch, did some work, committed and then push origin'd it, but that created a branch under the Big_project repo on github. Then I kind of went rogue and changed the upstream url to the sub_project repo whiiiiich uploaded the entire Big_project into the sub_project repo on my branch. Luckily it's only 75Mbs, but that was a dumb move.

This is academia so the expectation is kind of that I fix this myself.

So I have two questions:
1) How do I fix this?
2) How should I have approached this from the beginning. The most that I can see is submodules, but I don't quite get it.

EDIT: Okay I've deleted the branches and then just did a git init in the variation_sets, but it looks like I forgot to merge it, which in my defense I tried to do but it was giving me an error

bollig fucked around with this message at 13:25 on Apr 25, 2018

teen phone cutie
Jun 18, 2012

last year i rewrote something awful from scratch because i hate myself
When you are trying to run git rebase with a bunch of commits, each of which has a merge conflict is the process, as follows?

> git rebase develop
fix merge conflicts
commit
> git rebase —continue
fix merge conflicts
commit
Push to remote

Really having trouble with this today

chutwig
May 28, 2001

BURLAP SATCHEL OF CRACKERJACKS

Grump posted:

When you are trying to run git rebase with a bunch of commits, each of which has a merge conflict is the process, as follows?

> git rebase develop
fix merge conflicts
commit
> git rebase —continue
fix merge conflicts
commit
Push to remote

Really having trouble with this today

Basically yes, what part of the process is causing issues?

teen phone cutie
Jun 18, 2012

last year i rewrote something awful from scratch because i hate myself
I think my issue was that I wasn’t committing after resolving, but we’ll see when I get into work tomorrow

necrotic
Aug 2, 2005
I owe my brother big time for this!
It won't let you do anything until you resolve the conflict and continue, or abort the rebase entirely. Status command tells you what your options are when rebasing or cherry picking.

teen phone cutie
Jun 18, 2012

last year i rewrote something awful from scratch because i hate myself
What if you skip the patch and just fix all the merge conflicts in the last problematic commit?

necrotic
Aug 2, 2005
I owe my brother big time for this!
If you skip the patch it won't be included.

teen phone cutie
Jun 18, 2012

last year i rewrote something awful from scratch because i hate myself
Right but what if the commit after that deals with the same file? Would you then just skip to the commit where the file is most up-to-date?

necrotic
Aug 2, 2005
I owe my brother big time for this!
That's not how it works. Skipping a patch means the changes in that patch will not be present at the end of the rebase.

necrotic
Aug 2, 2005
I owe my brother big time for this!
If you don't want to deal with conflicts a bunch of times squash the branch first so its one commit, or just merge in the other branch and resolve it all in the merge commit.

raminasi
Jan 25, 2005

a last drink with no ice

bollig posted:

Hello everyone this is going to be a longish post, I'm kind of a noobie at git/github and I thought I knew more than I did. I've started a new remote job and the project I'm working on has like one overarching project and then some subprojects so the folder structure is sort of like this:

code:
Big_project/
     sub_project/folder/shit_im_working_on.py
So to get started, I cloned Big_project and then cloned sub_project into its corresponding folder. However when I git init'd, I did it in the Big_project folder and its origin url is the Big_project repo.

I created a branch, did some work, committed and then push origin'd it, but that created a branch under the Big_project repo on github. Then I kind of went rogue and changed the upstream url to the sub_project repo whiiiiich uploaded the entire Big_project into the sub_project repo on my branch. Luckily it's only 75Mbs, but that was a dumb move.

This is academia so the expectation is kind of that I fix this myself.

So I have two questions:
1) How do I fix this?
2) How should I have approached this from the beginning. The most that I can see is submodules, but I don't quite get it.

EDIT: Okay I've deleted the branches and then just did a git init in the variation_sets, but it looks like I forgot to merge it, which in my defense I tried to do but it was giving me an error

I'm confused - why you are running git init at all? That's for creating new repos.

Submodules can kind of suck to work with. See if one of these StackOverflow answers helps.

reversefungi
Nov 27, 2003

Master of the high hat!
Grump, are you doing this all through the console? I started off doing everything through the console but honestly using a UI like GitKraken just makes life so much easier. My opion is that it's not worth the hassle to not use it unless you're forbidden from using git UIs for some strange reason. Rebasing through GitKraken is as simple as selecting the branch you want to rebase on top of, then working through the conflicts in the diff view. Very easy and takes a few minutes at most.

teen phone cutie
Jun 18, 2012

last year i rewrote something awful from scratch because i hate myself
I run the commands in the console and work out the conflicts in VS Code.

Seems simple enough. I’m just finding it hard to figure out what the console is trying to explain sometimes. This is my first job working on a project that more than 2 devs are making changes to, so I’m having trouble figuring out the best way to pull down the develop branch from the project and merge with my feature branch in my forked project.

It’s a work in progress honestly and my imposter syndrome is acting up big time.

teen phone cutie fucked around with this message at 02:32 on May 4, 2018

ChickenWing
Jul 22, 2010

:v:

Grump posted:

Right but what if the commit after that deals with the same file? Would you then just skip to the commit where the file is most up-to-date?

so that's not quite how git works - every commit you resolve is applying its own changes, not providing the most recent version of the file. So if (on the same file) commit A edited line 10-20, commit B edited lines 50-60, and commit C edited lines 130-150, and you skipped A and B during your rebase, C would only apply the changes to lines 130-150 , not 10-20 or 50-60.

IMO don't rebase unless it's commanded by on high. People need to be less mad about merge commits.

poemdexter
Feb 18, 2005

Hooray Indie Games!

College Slice
I rebase my feature branches every morning because I'd rather keep my poo poo up to date and avoid a merge conflict down the road. I also don't want to merge branches into my feature branch because I don't want to carry commits that might be reverted later. My feature branches should contain just my commits. Rebase is dead simple.

Also, I've used SourceTree in both OSX and Windows and refuse to use the cli because I'm 1000% more efficient and can typically fix poo poo that others mess up super easy in SourceTree. Just my opinion though.

necrotic
Aug 2, 2005
I owe my brother big time for this!
Any reversions should be new commits anyway so you'd still carry them by rebasing.

nielsm
Jun 1, 2009



Grump posted:

When you are trying to run git rebase with a bunch of commits, each of which has a merge conflict is the process, as follows?

> git rebase develop
fix merge conflicts
commit
> git rebase —continue
fix merge conflicts
commit
Push to remote

Really having trouble with this today

> git rebase develop
fix merge conflicts
> git add fixedfile.py
> git rebase --continue
fix more conflicts, add fixes, continue rebase, until done
> git push

When fixing conflicts during rebase you do not commit yourself, leave the fixed files in the index.
The only time you'd use 'git commit' during a rebase operation, I can think of, is when using the 'edit' action in an interactive rebase.

teen phone cutie
Jun 18, 2012

last year i rewrote something awful from scratch because i hate myself
Just wanted to report back saying that I now understand how git rebase works and it’s not as scary as I once thought.

Thank you

necrotic
Aug 2, 2005
I owe my brother big time for this!
Yeah none of git is scary once you understand it. It (and other distributed VCS) is just different from older VCS in that only patches matter, nothing else exists.

chutwig
May 28, 2001

BURLAP SATCHEL OF CRACKERJACKS

The thing that really made Git click for me is understanding that it's essentially a filesystem where blobs are inodes and refs (branches/tags) are symlinks, and then the rest of the toolkit is dedicated to manipulating/merging/comparing the content. Spending a few hours spelunking around a toy repo with git cat-file demystifies pretty much everything about Git.

necrotic
Aug 2, 2005
I owe my brother big time for this!
Yeah you can even browse around the .git folder and make changes directly there (don't, but you can). It's just files and symlinks.

Axiem
Oct 19, 2005

I want to leave my mind blank, but I'm terrified of what will happen if I do
For me what made git click was when I realized it was just a giant tree, where each commit is just a dot on the tree, and every named thing (branch/tag) is just a pointer to a dot on the tree. For me, the ability to visualize the DAG (as it were) was the point where I started being able to figure out how to do things on the command line beyond the basics.

ChickenWing
Jul 22, 2010

:v:

Axiem posted:

For me what made git click was when I realized it was just a giant tree, where each commit is just a dot on the tree, and every named thing (branch/tag) is just a pointer to a dot on the tree. For me, the ability to visualize the DAG (as it were) was the point where I started being able to figure out how to do things on the command line beyond the basics.

Yeah this was what made it click for me too. Every time I did something with git and was all "wow this is actual real magic" my tech lead just replied "git is a graph and you are just doing things to the graph" and then one day I was like "oh right that makes sense" and now I am the office git guy :sun:

Adbot
ADBOT LOVES YOU

poemdexter
Feb 18, 2005

Hooray Indie Games!

College Slice
Make everyone else download SourceTree so they can see the magic too. It's pretty easy to understand git when you can see what you are doing.

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