gitbranchgit-commit

git branches are not visible


The code was uploaded and I see it in my account on github.com

I tried creating two branches and uploaded the code with some changes from my terminal i.e. two commits, in terminal it didn't show any error, but in my repo, I am not able to see my branches and there the commit seems to be only 1 master commit alone

So I tried running my git log in terminal

macbook-MBP Ojaak % git log
commit b5b17e3108139d7904c905d1d1aefe22a7395180 (HEAD -> siva)
Author: sk-master <siv@gmail.com>
Date:   Mon Jun 28 18:00:43 2021 +0530

    siva test

commit eea6ed5fe18dedd60ab714e1d3828cc2487cba3a (Dani)
Author: sk-master <siv@gmail.com>
Date:   Mon Jun 28 17:23:28 2021 +0530

    dani updated by 26th June

commit 8e9f41d4245dfb1e2e9f4ed1d00ee12d1b081240 (origin/master, master)
Author: sk-master <siv@gmail.com>
Date:   Mon Jun 28 16:28:58 2021 +0530

    code worked by Sarah

Here it shows the branches name and their commit time etc but those are not available in github repo

I learned about git from the following youtube playlist https://www.youtube.com/watch?v=GZILYABgAoo&list=PLhW3qG5bs-L8OlICbNX9u4MZ3rAt5c5GG&index=5

but it is a 2016 video


Solution

  • You need to understand some basic concepts about git. Once you understand them it will be easy to work with git.

    commit

    A commit is a chunk of work that's stored at a repo in a branch.

    pull

    The process of downloading commits from another repo. The default repo you download from is by default called origin.

    push

    The process of uploading commits to another repo. The default repo you upload to is by default called origin.

    branch

    In the versioning tree, a branch is a well-defined set of commits. You can create a branch as

    git branch yourbranch
    

    which, according to the wording of your question you did successfully. You can switch branches via

    git checkout yourbranch
    

    which was also correctly done by you according to the wording of your question.

    You missed uploading your branch:

    git checkout thebranchtobeuploaded
    git push -u origin thebranchtobeuploaded
    

    The checkout step is not always necessary to be performed, if you are on the branch which you intend to upload, then you can omit the checkout step, I nevertheless have given you a bullet-proof approach. Once you do the git push -u origin somebranch step, your branches should appear on the origin repo. You can use multiple repos as well, but that's not the topic of this question.