Git mess


#1

Let me start this with the fact that I’ve just never wrapped my head around git and I never feel very confident working with it.

My local JUCE copy is somewhere around 5.1.2 on Develop. I know about a change that I made to it that I always make and I have a stash for it so I can always add it to the latest. I also know that I made some accidental changes to some files that I don’t care about.

My question is: How do I reset/revert/checkout/whatever-the-hell-git-calls-it and just update my local copy so it’s at the latest on Develop?

Thank you so much.


#2

My workflow is to create my own patched branch:

git checkout develop
git checkout -b myBranch
# now do your changes
git add <changed files>
git commit -m "What did I do..."

Now later, when juce progresses, call this to get new changes into your branch

git pull origin develop

If there are conflicts, you will have to merge them and commit that change. But most changes will be applied automatically…

Hope that helps as a starting point…


#3

Thanks. I started with the ‘git checkout develop’ and I get:

Your branch is ahead of 'origin/develop' by 10 commits.

I tried doing a fetch but that didn’t help.


#4

If you want the code in your local copy to match origin/develop, simply do:

git fetch
git checkout origin/develop

but then you are not on a branch.

If you want your local develop branch to match origin/develop:

git fetch 
git checkout develop 
git reset --hard origin/develop

Any commits made on that branch will be lost.


#5

It seems that git reset --hard origin/develop did the trick.

Thank you both.


#6

I’ve found it extremely helpful to use a GUI client (I use SourceTree) for managing everything. It helped me wrap my head around git much more quickly by smoothing the learning curve and allows me to get a much better picture of the state of my repo. I only use the command line when I need to do some crazy configuration or fix a gnarly versioning problem.


#7

I use SourceTree and I wish I found it more helpful. I can’t tell you how many times I’ve tried to do something in SourceTree and received an error that was obtuse and confusing. I’m sure that it’s because I just haven’t taken enough time to wrap my head around git, but I just don’t feel comfortable with it. Thanks again.


#8

I find SourceTree incredibly frustrating, I often resort to the command line but when things get complex a GUI is definitely beneficial. I recommended GitKraken https://www.gitkraken.com/ especially if you’re on Windows where I’ve found SourceTree to be almost unusable.


#9

SourceTree Windows is definitely a train wreck (I use both macOS and Windows SourceTree extensively), but according to the SourceTree blog they’re actively trying to improve it. It’s been improving, albeit very slowly.

I’ve tried GitKraken many times since its first beta and haven’t been able to latch onto it quite like SourceTree… to me it feels like it abstracts away too much of git, but that may mean it may work better for folks who don’t already have working knowledge of git.


#10

For SourceTree, I feel like their update to 2.0 when the GUI was redone screwed up everything. It was far more intuitive before. Still painful to add SSH keys through pageant instead of having them stored in ST, still painful to open an existing repository.


#11

I was an happy user of SourceTree too, until they changed it in version 2 for Windows.
I’ve been searching for an alternative these last days and tried pretty much all those listed in
git-scm.com.
GitKraken was one of those that I liked, but currently the one that has the most chances to become my next favorite is SmartGit: http://www.syntevo.com/smartgit/


#12

On Windows, specifically for its 3-way merge and diff tools, TortoiseGit all the way.

I’ve used both SourceTree and GitKraken, and have to say that SourceTree is stupid for not having consistent features across platforms (eg: no force-push support on Windows but supported on macOS.).

If you want to check out other GUI tools, the official git site lists a bunch: https://git-scm.com/downloads/guis/

TBH, nowadays I’m almost entirely on command-line. It’s become much easier to learn the commands so I can easily switch between Win/mac/Linux without unnecessarily learning different GUI tools. Takes a lot of time and patience but I found it worthwhile the energy - and you should be perfectly ‘ok’ with breaking your repo and its clone at first, till you get the hang of it.


#13

I use their DeepGit tool lately for git-blames and it’s excellent


#14

The JUCE team uses SmartGit and we rarely have to drop to the command line to do anything.


#15

Does it provide a diff tool and have 3 way merge support?


#16

Yes. It’s free for non-commercial use, so you can give it a try.


#17

Been using SmartGit for many years, and it’s excellent for most tasks.

Particularly useful is the built-in support for GitFlow workflow, to fascilitate feature branch management.


#18

My favorite is Tower:

https://www.git-tower.com/mac/

Supports submodules and GitFlow and basically all common git commands.


#19

We have multiple patches that we keep up-to-date with the latest develop branch: each patch has its own branch that the latest JUCE upstream changes are merge to. A ‘patches’ branch joins all the patches we apply. We have scripted the git commands to automate the sync. Here is the public repository, as a fork on github: https://github.com/francoisbecker/JUCE


#20

So you keep merging ROLI/develop to each of your fix feature branches, and have a script to merge all of them? We just have our branch with all the fixes which we merge new changes into, but your mode certainly sounds better organised. Could you share your script? :slight_smile: