AIX Open Source

AIX Open Source

Share your experiences and connect with fellow developers to discover how to build and manage open source software for the AIX operating system

 View Only
  • 1.  AIX 7.3 - git 2.35.1 -- git branch & git switch not working

    Posted Thu August 18, 2022 08:32 AM
    Good day,

    I've installed git on our AIX 7.3 LPAR to manage our Bash scripts (amongst other things).  I successfully created a git repo within a demo directory structure however I'm finding that certain sub-commands either return nothing or error out, details below:

    # whoami
    root
    # echo $PATH
    /opt/freeware/bin:/usr/bin:/etc:/usr/sbin:/usr/ucb:/usr/bin/X11:/sbin:/usr/java8_64/jre/bin:/usr/java8_64/bin:/usr/local/bin
    # oslevel -s
    7300-00-02-2220
    # rpm -qa | grep git
    git-core-2.35.1-1.ppc
    git-2.35.1-1.ppc
    git-core-doc-2.35.1-1.noarch
    #
    # git init
    Initialized empty Git repository in /home/mundays/scripts/.git/
    # git status
    On branch main
    
    No commits yet
    
    Untracked files:
      (use "git add <file>..." to include in what will be committed)
            curl_logonv8.xml
            curl_logonv9.xml
            demo.sh
            demo1.sh
            lpargrouplist.xml
            lparlist.xml
    
    nothing added to commit but untracked files present (use "git add" to track)
    #
    ### git branch fails to list "main" branch
    #
    # git branch --list
    #
    ### git branch <new-branch> errors out
    #
    # git branch develop
    fatal: not a valid object name: 'main'
    # git switch -c develop
    Switched to a new branch 'develop'
    # git status
    On branch develop
    
    No commits yet
    
    Untracked files:
      (use "git add <file>..." to include in what will be committed)
            curl_logonv8.xml
            curl_logonv9.xml
            demo.sh
            demo1.sh
            lpargrouplist.xml
            lparlist.xml
    
    nothing added to commit but untracked files present (use "git add" to track)
    #
    ### git branch fails to list "main" and "develop" branches
    #
    # git branch --list
    #
    ### git switch back to "main" errors out
    #
    # git switch main
    fatal: invalid reference: main
    #​

    Clearly something is amiss however I'm not sure what that might be and/or where to look to fix it.

    Any advice/guidance would be very welcome.

    Many thanks, Steve


  • 2.  RE: AIX 7.3 - git 2.35.1 -- git branch & git switch not working

    Posted Thu August 18, 2022 08:51 AM
    not clear why you are expecting the "main" branch to exist per default. beside this, you need at least one commit do see the standard branch, which is NOT necessarly named "master" since 2020.
    guess you need to read the git manual.

    ------------------------------
    I regret starting this entire conversation
    ------------------------------



  • 3.  RE: AIX 7.3 - git 2.35.1 -- git branch & git switch not working

    Posted Thu August 18, 2022 09:20 AM
    Ah!  Ok, so even though my initial git status says that I'm "On branch main" I have to create that branch too, I thought the "git init" would have done that itself, I guess not,.  This would explain why it errored out referencing main.

    When in the "develop" branch I did do a commit and now see "develop" when running the "git branch" command.

    Many thanks, Steve


  • 4.  RE: AIX 7.3 - git 2.35.1 -- git branch & git switch not working

    Posted Fri August 19, 2022 09:06 AM
    ** Update **

    Even though git status said I was in the "main" branch it wasn't until I'd committed a file to "main" that it appeared in the output of git branch.  All looking much better now.


  • 5.  RE: AIX 7.3 - git 2.35.1 -- git branch & git switch not working

    Posted Fri August 19, 2022 09:39 AM
    The name of the default branch is configurable with git-config, the default changed to "main" a while ago. You don't have to explicitly create that branch, the first commit goes there by default.

    Like you've discovered, if there is nothing committed then you really don't have a branch yet (it would not make sense to have a branch with no content).

    There are things that git configures per user and others that it configures per repo or both. That isn't completely obvious unless you know to look for it, though it does make sense once you know.

    Since you are new to git, I'll just say that the free book is worth every second you spend with it. For my own use, the following tasks/topics have been very helpful:

    - amending the last commit (message or otherwise)
    - creating/using branches
    - understanding "remotes" and how/when to push local branches
    - the difference between "merge" and "rebase"
    - git diff
    - git status
    - git is neither GitHub nor GitLab
    - git restore <- this is your friend

    I offer that list because it seems to cover the things that the people I help with git usually run into first. Otherwise, it depends on what you're doing, but if you conceive of a question that you want to ask about your code history, git can likely answer it.

    -- 
    Stephen L. Ulmer
    Enterprise Architect
    Mainline Information Systems
    (m) 352-870-8649






  • 6.  RE: AIX 7.3 - git 2.35.1 -- git branch & git switch not working

    Posted Fri August 19, 2022 01:55 PM
    Stephen,

    Thank-you very much for all the extra info.  Apologies for the Newbie (Git) questions.

    Regards, Steve