Git's getting in my way again


  • ♿ (Parody)

    @thecpuwizard said in Git's getting in my way again:

    The message(s) from local commands (such as checkout) are referring to the relationship between these local items.

    Yes, I agree, that's what they meant to convey in the message. It's just using the wrong words. Nowhere in the message were the words "working copy" or any synonym.

    @thecpuwizard said in Git's getting in my way again:

    Your local clone IS a Repository (almost certainly implemented as a hidden .git folder). The contents of these items are named. There is nothing "remote" involved directly here.

    Go back and look at what @masonwheeler posted. origin is a remote repository. Otherwise he couldn't pull from it.

    @thecpuwizard said in Git's getting in my way again:

    It is only when a command related to remote operations (such as fetch) are used that the name of the item is resolved to a URL and the activity involves something that is remote.

    Yes, that's obviously what git means by that message. But then it shouldn't be talking about the remote repository, should it?

    @masonwheeler said in Git's getting in my way again:

    $ git checkout develop
    Switched to branch 'develop'
    Your branch is up-to-date with 'origin/develop'.
    $ git pull origin
    remote: Counting objects: 21, done.
    remote: Compressing objects: 100% (21/21), done.
    remote: Total 21 (delta 15), reused 0 (delta 0)
    Unpacking objects: 100% (21/21), done.
       b505189..4209aef  develop    -> origin/develop
     * [new branch]      release/1.5 -> origin/release/1.5
       9176dba..04c4dae  releases   -> origin/releases
     * [new tag]         version1.4 -> version1.4
    Updating b505189..4209aef
    Fast-forward
     file1.py   |  8 ++++++--
     file2.py   | 12 ++++++++++--
     2 files changed, 16 insertions(+), 4 deletions(-)
    

    Look at the first command!

    $ git checkout develop
    Switched to branch 'develop'
    Your branch is up-to-date with 'origin/develop'.
    

    The first line of the response is talking about your working copy. What do you suppose "Your branch" refers to? Now, what does "origin/develop" refer to? "Your branch" to me is the branch that I have in my local repo. You say that "origin/develop" is also referring to that exact same thing. So...why would you put that message in? It makes no sense. It only makes sense if it's talking about the remote branch.

    Why even bring that up if you're only looking at local stuff?



  • @boomzilla said in Git's getting in my way again:

    OK, I will try one more time..

    $ git checkout develop
    Switched to branch 'develop'

    To prepare for working on <branch>, switch to it by updating the index and the files in the working tree, and by pointing HEAD at the branch. Local modifications to the files in the working tree are kept, so that they can be committed to the <branch>.

    Your branch is up-to-date with 'origin/develop'.

    Their are no differences between the files in the working tree (although there could have been) and the files in the (local) branch

    $ git fetch origin

    Yes, I changed it, because with a fetch the material would have been copied from the REMOTE implementation of origin to the LOCAL implementation of origin, but the working tree would NOT have been updates.

    If checkout had been run again at this point, there would have been differences between the LOCAL copy of origin and the working folder and they would have been displayed.

    The git documentation even alludes to this in multiple places.

    git fetch can fetch from either a single named repository or URL, or from several repositories at once if <group> is given and there is a remotes.<group> entry in the configuration file. (See git-config[1]).
    When no remote is specified, by default the origin remote will be used, unless there’s an upstream branch configured for the current branch.

    Note that is does not say "origin" will be used.

    When doing training, avoiding the local names, and specifically using the URL often helps avoid confusion in this area.


  • Fake News

    @boomzilla said in Git's getting in my way again:

    The first line of the response is talking about your working copy. What do you suppose "Your branch" refers to? Now, what does "origin/develop" refer to? "Your branch" to me is the branch that I have in my local repo. You say that "origin/develop" is also referring to that exact same thing. So...why would you put that message in? It makes no sense. It only makes sense if it's talking about the remote branch.

    Why even bring that up if you're only looking at local stuff?

    • Git is local-only by default.
    • develop is a branch you can modify directly by committing, resetting, rebasing, etc.
    • origin\develop is what your local git repo thinks the state of the remote branch is. Only a fetch / pull / push will update it. Checkout will mention it if the develop branch marked it as an upstream target branch, but that is informational. Again, no sync is done with the remote repo.
    • https://github.com/whatev/grit/ is the remote repo containing a develop branch with potential changes by someone else.

    If you don't run a fetch / pull / push, your local cache of origin\develop will never change, hence why checking out develop will always say "Your branch is up to date" or "Your branch is x commits ahead of origin\develop".

    If you do a git fetch --all and there are actual changes in the remote repo, then running git checkout develop will show you a message like "Your branch is x commits ahead and x commits behind origin\develop".



  • @jbert - Thank YOU!!!!!

    [PEDANTRY: there are some implications of the word "cache" that really don't apply, so "copy" might be a better word]


  • ♿ (Parody)

    @jbert said in Git's getting in my way again:

    origin\develop is what your local git repo thinks the state of the remote branch is. Only a fetch / pull / push will update it. Checkout will mention it if the develop branch marked it as an upstream target branch, but that is informational. Again, no sync is done with the remote repo.

    Yes, but there is literally no reason to mention it at all when you do a checkout. It does nothing but mislead.


  • 🚽 Regular

    @boomzilla said in Git's getting in my way again:

    The first line of the response is talking about your working copy. What do you suppose "Your branch" refers to?

    The (local) branch develop, as you very well know.

    @boomzilla said in Git's getting in my way again:

    Now, what does "origin/develop" refer to?

    The local copy of origin's develop branch.

    @boomzilla said in Git's getting in my way again:

    "Your branch" to me is the branch that I have in my local repo.

    It is.

    @boomzilla said in Git's getting in my way again:

    You say that "origin/develop" is also referring to that exact same thing.

    Only because neither have you added any commits to develop, nor has origin/develop been updated with more commits since it was last fetched.

    @boomzilla said in Git's getting in my way again:

    So...why would you put that message in? It makes no sense. It only makes sense if it's talking about the remote branch.

    It's referring to a local copy of a remote branch. So things aren't quite so binary.

    @boomzilla said in Git's getting in my way again:

    Why even bring that up if you're only looking at local stuff?

    Because they could be different. It could say your branch is N commits behind origin/develop. Or it is M commits ahead. Or both.

    But they aren't. So mentioning it may be confusing, yes.

    --

    Paraphrasing blakeyrat: you're making me defend git. Stop it.


  • 🚽 Regular

    $ git checkout develop Switched to branch 'develop'. Your branch is up-to-date with 'origin/develop', which was last updated 30 minutes ago. (use 'git fetch origin' to update) $

    This is how I'd fix this.



  • More fun..... Usingthe multiple remotes I listed early, and assuming there is a branch called "my-branch" in each of them...

    $ git checkout -b my-branch origin/my-branch
    $ git checkout -b my-branch bakkdoor/my-branch
    $ git checkout -b my-branch cho45/my-branch
    $ git checkout -b my-branch koke/my-branch
    `
    Watch how long the messages can possibly get, and the value of the message showing which branch (From local storage) is now in your working folder....



  • @dkf said in Git's getting in my way again:

    @thecpuwizard said in Git's getting in my way again:

    An increasing number of companies are adopting branchless development

    That's utterly moronic; I feel stupider just from having read what you've written about it!

    Come to my place. we have a single master branch (+ bugfix braches) where everyone pushes to and Gerrit to "solve" the branching for feature development



  • @homobalkanus said in Git's getting in my way again:

    we have a single master branch (+ bugfix braches) where everyone pushes to and Gerrit to "solve" the branching for feature development

    Gerrit is a pretty interesting tool, and can work great in many circumstances. :)

    I was referring to something much deeper [and definitely more appropriate for a different discussion...] that gets down to the order in which code is written, work is scheduled, and basically involves a bit of a mind shift for the entire team. Definitely an investments, and not appropriate for all environments - but quite probably more effective in more environments than many think...

    The fundamental precepts:

    1. Code that is not called by other (production) code, is VERY unlikely to have an impact.
    2. Code that can dynamically be swapped in/out without rebuild mitigates risk [DIP and OCP parts of SOLID]
    3. Code that has a single responsibility, and completely handles that responsibility -very small responsibilities [SRP of SOLID]
    4. Management tools to control access [e.g. Feature Flags such as https://launchdarkly.com/


  • @blakeyrat said in Git's getting in my way again:

    Any message from a piece of software that requires several paragraphs of explanation is a bug.

    What about messages that can't be explained even with several paragraphs ?

    0_1505136305981_0124eb98-9cf5-4626-baed-51f0b8dca571-image.png


  • :belt_onion:

    a.) @JBert explains these things much better than I do (or TBH almost anyone else in this topic is doing).

    @zecc said in Git's getting in my way again:

    $ git checkout develop Switched to branch 'develop'. Your branch is up-to-date with 'origin/develop', which was last updated 30 minutes ago. (use 'git fetch origin' to update) $

    This is how I'd fix this.

    b.) This would be outstanding. Maybe with the additional parts of the message being suppressed if the last fetch was < 1 hour ago or so (configurable) for those people like me who have the "update OCD" and will fetch just to try to make that message go away.

    ETA: But of course, if you change the input/output, that may cause problems since the CLI is the API... hopefully on something as simple as checkout just exit status would be checked, but you never know. So I'm sure this kind of change is something that would never, ever make it in to Git. It'll just make it into one of those "better Git" extensions/shell extensions or some such and the baseline functionality will still confound the 99% of users who don't have the extension.



  • @zecc said in Git's getting in my way again:

    last updated 30 minutes ago

    As far as I can determine Git does not track that...so it would be more than changing a message....



  • @timebandit OMG it's hilarious guys because Windoze Windoze is so bad look I spelled it with a Z and look at me spell Micro$oft with a dollar sign isn't that hilarious? jokes about windowz bluescreens will never get old and did you see that one photoshop where someone made Bill Gate$$$ into a borg from Star Trek LOL



  • @masonwheeler said in Git's getting in my way again:

    @raceprouk said in Git's getting in my way again:

    @masonwheeler said in Git's getting in my way again:

    FTFY, because 99.99% of software projects are centralized.

    That might have been true in 1982, but nowadays, not so much.

    How many projects have you worked on where you pushed to something other than the central repo? (Not counting Github, which goes out of its way to force that paradigm on you whether it makes sense or not.)

    This is my daily workflow.

    Push to fork -> PR to central repo.



  • @raceprouk said in Git's getting in my way again:

    @masonwheeler said in Git's getting in my way again:

    FTFY, because 99.99% of software projects are centralized.

    That might have been true in 1982, but nowadays, not so much.

    I haven't worked for a company yet that doesn't work on a centralized model. And now we use git. In a centralized model.



  • @thecpuwizard said in Git's getting in my way again:

    @masonwheeler said in Git's getting in my way again:

    Does anybody?

    And yet, the mass migration to Git from well understood and appropriate alternatives continues.....

    Yeah, and we moved from BetaMax to VHS. Marketing trumps technology every time.



  • @dcon said in Git's getting in my way again:

    Yeah, and we moved from BetaMax to VHS. Marketing trumps technology every time.

    I had to upvote your post because I agree with the truth of that... Wish there was an emoji for "I agree, but hate the fact"



  • @thecpuwizard said in Git's getting in my way again:

    Wish there was an emoji for "I agree, but hate the fact"

    :magnets_having_sex:

    It's multi-purpose.



  • @blakeyrat said in Git's getting in my way again:

    @thecpuwizard said in Git's getting in my way again:

    Wish there was an emoji for "I agree, but hate the fact"

    :magnets_having_sex:

    It's multi-purpose.

    :magnets_having_sex: is the right emoji in every situation.



  • @blakeyrat (and ben_lubar) Thanks!


Log in to reply