Search code examples
gitbitbucketgit-fetch

Why git fetch doesn't download anything?


I'm trying to download my project which is uploaded on bitbucket on my local directory. As far as I know about git fetch, it should download the project (but not merge it).

Well I have a connection to my repository as well, an here is what I've done:

enter image description here

And this is the result of git fetch: (as you see it in the image above)

$ git fetch
remote: Counting objects: 114, done.
remote: Compressing objects: 100% (104/104), done.
remote: Total 114 (delta 6), reused 114 (delta 6)
Receiving objects: 100% (114/114), 10.32 MiB | 2.03 MiB/s, done.
Resolving deltas: 100% (6/6), done.
From https://bitbucket.org/lamtakam/lamtakam
 * [new branch]      master     -> origin/master

But nothing downloaded ..! Why? As you see, my local directory is empty (except .git folder). What's wrong?


Solution

  • git fetch simply update(s) your .git folder with the packed data.
    It does not update your working directory only the internal .git folder.

    Once all the data downloaded you can checkout any branch you want to work on.

    git fetch

    The git fetch command imports commits from a remote repository into your local repo (no to be confused with the local working directory).

    The resulting commits are stored as remote branches instead of the normal local branches that we’ve been working with. This gives you a chance to review changes before integrating them into your copy of the project.


    To see the list of available branches use the -a flag

    # display all available branches
    git branch -a
    

    enter image description here

    In order to work on specific branch simply check out the desired branch

    enter image description here