Skip to end of metadata
Go to start of metadata

On this page, you'll learn how to add code to your repository. At this point, you have created a bb101repo which is a private repository that only you, the owner, can see or work in. This is not typical. Usually, you want some help on a project and you won't be the only one working in a repository. However, this is a tutorial and right now you need to learn without being distracted by other people. We'll add more people to your project later.

Important reminders about these instructions

The git commands on this page are for a GitBash terminal. However, the commands are nearly identical in a Mac OSX terminal and in an Ubuntu Linux terminal. You shouldn't have any trouble following along but if you do, please comment on the page and we'll make corrections.

This tutorial teaches you a little Git first and later a little Mercurial. All the operations that you do with Git have Mercurial equivalents and of course the reverse is also true. You are free to use Mercurial exclusively with this tutorial if you want, but you'll need to do that on your own.

Step 1. Clone your repository to your local system

Open a browser and a Git Bash window (also called a terminal window) from your desktop.  The terminal window on your local system which is the system you code on as opposed to the remote Bitbucket server. After opening the terminal window, do the following:

  1. Navigate to your home (~) directory.

    As you work with code, you will find that you have multiple repositories that you work in. It is a good idea to create a directory to contain all those repositories. Generally, this is your home directory but it can be anywhere you want it to be.
  2. Create a directory to contain your repositories.

    mkdir repos
  3. If you haven't already done so, go to Bitbucket in your browser and log into your Bitbucket account.
  4. Go to your bb101repo Overview page.
  5. Click Clone button.
    The system displays a pop-up clone dialog. By default, the clone dialog sets the protocol to HTTPS. Leave it there.
  6. Click on the command line field that accompanies the protocol.
    When you click on the command field it automatically highlights the command for you.
  7. Copy the highlighted git command.
  8. Switch back to your terminal window.Change directory to your new repositories directory.

    cd repos

    Paste the command you copied from Bitbucket onto the command line and press Return.

     Click to view GitBash cut 'n paste tips...

    Use the menu to go into Mark mode and then select text. Pressing Enter adds the text to the clipboard. Paste text by pressing INSERT on your keyboard or using the menu.


    Git will ask you for the repository password. This is the password you entered when you created your Bitbucket account.  If you created an account by linking to Google or Facebook and you are following this tutorial, you should have created a password already.

    Windows password error

    In some versions of the Microsoft Windows operating system and Git you might see an error similar 
    to the one in the following example.
    Windows clone password error example

    If you get this error enter the following at the command line:

    git config --global core.askpass

    Then go back to step 4   and repeat the clone process. The bash agent should now prompt you for your password. You should only have to do this once.

  9. Enter your password.
    Git creates the repository but warns you that you have cloned an empty repository. At this point, your terminal window should look something like this:

    $ cd ~/repos
    $ git clone https://newuserme@bitbucket.org/newuserme/bb101repo.git
    Cloning into 'bb101repo'...
    Password
    warning: You appear to have cloned an empty repository.

    You already knew that your repository was empty right? Recall that you have added no source files to it yet.

  10. List the contents of your repos directory and you should see your bb101repo directory in it.

Step 2. Explore your repository and fix a problem

Git said you had cloned an empty repository. This is true, your repository is empty but the directory that git created is not entirely empty. List the contents of your local repository – including the hidden files. A local repository is the copy of a repository you have on your local system. After listing the contents of your local repository, you should see something like this:

$ ls -al bb101repo/
total 0
drwxr-xr-x 3 manthony staff 102 Dec 14 10:50 .
drwxr-xr-x 3 manthony staff 102 Dec 14 10:50 ..
drwxr-xr-x 9 manthony staff 306 Dec 14 10:50 .git
$ 

The .git directory contains special files and directories used by the Git system. For now, you should be aware that it is there.

Notice that Git went ahead and named your repository's directory with the same name as you did when you created it. You could have cloned the repository under a totally different name. For example, you could cloned the repository to a directory called bb101repo-practice. The advantage of this name is that it provides a clue about what you were going to do with clone. In fact, it is good not to simply use the repository name when you clone but indicate what you are doing with the clone. Why don't you fix that right now:

  1. Remove the repository you just created.

    rm -irf bb101repo/
  2. Reissue the clone command but this time give Git a name that indicates what you are doing.
    For example, you might want to call the clone bb101repo-practice:

    $ git clone https://newuserme@bitbucket.org/newuserme/bb101repo.git bb101repo-practice

    Again, Git will tell you that you are cloning an empty repository. 

  3. List your ~/repos directory, you should see something similar to the following:

    $ ls ~/repos
    bb101repo-practice

Great. Now you are ready to add content to your repository.

Step 3. Create a file, add it locally, and push it to the Bitbucket Server

Bitbucket lets you set a repository's description but you may want to provide a file to get you started. The commands for this section will appear in the Command line section of the Repository setup page.

  1. Go to your terminal window and navigate to the top level of your local repository.

    cd ~/repos/bb201repo-practice/
  2. Click the I'm starting from scratch section of the Repository setup page.
    We have already completed the first portion of this process (Set up your local directory) in great detail. However these commands are available when you set up a new repository for your own use.

  3. Copy the first command line from the Create your first file, commit, and push and past into your terminal window.

    echo "Daniel  Stevens" >> contributors.txt

    You've just created a file!

  4. Go ahead and get the status of your local repository.
    The git status command tells you about how your project is progressing in comparison to your Bitbucket repository. You should see something like this:

    dstevens:teams-in-space dstevens$ git status
    On branch master
    Your branch is up-to-date with 'origin/master'.
    Changes not staged for commit:
      (use "git add <file>..." to update what will be committed)
      (use "git checkout -- <file>..." to discard changes in working directory)
        modified:   contributors.txt
    no changes added to commit (use "git add" and/or "git commit -a")

    You can see that Git is aware that you created a file in your local repository. The status output also shows you the next step, the add.

  5. Tell git to track your new contributers.txt file using the git add command.

    git add contributors.txt

    You must perform this step before you can commit a file.   What happens if you run the status command now? Git sees that you have a new file in your local repository and that you can potentially commit it.

  6. Commit all the changes you added.
    Right now, the only change pending in your local repository is the new file. When you issue the commit command you see this:

    $ git commit -m 'Initial commit with contributors'
    [master (root-commit) fedc3d3] Initial commit with contributors
     1 file changed, 1 insertion(+)
     create mode 100644 contributors.txt

    Up until this point, everything you have done is local – that is on your local system.  It is not visible in your Bitbucket repository until you put it there with the push command.  You can test this to see if it is true by opening the Bitbucket bb201repo Overview page in your browser.  You should see that the Overview looks exactly as it did when you started.

  7. Go back to your local terminal window and push your committed changes using the git push command.
    You should see something similar to the following:

    teams-in-space-repository-2 dstevens$ git push -u origin master
    Counting objects: 3, done.
    Writing objects: 100% (3/3), 253 bytes | 0 bytes/s, done.
    Total 3 (delta 0), reused 0 (delta 0)
    To https://dans9190@bitbucket.org/teamsinspace/teams-in-space-repository-2.git
     * [new branch]      master -> master
    Branch master set up to track remote branch master from origin.
    

  8. Go to your Bitbucket bb201repo repository in your browser and click the Commits item on the menu bar.

    You should see a single commit on your repository. 
    Bitbucket traps a lot of information with your commit and shows it to you. You can see that the Author column shows the value you used when you configured the Git global file ( ~/.gitconfig).  

  9. Select the Source option.
    You should see that you have a single source file in your repository, the contributors.txt file you just added

Remember how the Overview page looked when you first created your repo? Take some time and explore a little. Click on buttons and travel down some links.

 

Next

Now, you have finished the simplest workflow between Bitbucket and a DVCS system. You created a local repository, added a new file to it, and pushed those changes to the Bitbucket repository. At this point you may have a few thoughts in your head such as:

  • Hey, I don't consider a contributers.txt file to be source code.
  • Aren't other people supposed to help me with my repository?
  • This Git stuff is fine but I want to use Mercurial.

The next page of this tutorial will resolve some of these thoughts because you will use the fork operation and use Mercurial to add code to another user's repository.

183 Comments

  1. Anonymous

    I thoroughly enjoyed this tutorial , very well written and the instructions are easy to follow, kudos.

    1. Thank you for this lovely comment.

       

    2. Anonymous

      yeah I agree with this Anon

      1. Anonymous

        And I agree with this Anon agreeing with that Anon

          1. Anonymous

            I also agree with Anon, Anon and that Anon. Oh and also the Anon below this comment.

             

              1. Anonymous

            1. Anonymous

              I find it interesting how all these anons could be the same person which isn't me.

            2. Anonymous

              this thread is going on and anon

              1. Anonymous

                and anon and anon

                1. Anonymous

                  anon anon!!

  2. Anonymous

    this is the excellent tutorial , very well written with screen shot and all instructions are easy to understand, Shakar

     

    Thanks a lot

  3. Anonymous

    Nice work guys! Just getting started with BitBucket and my first git repository every and have been setup without any issues and I can understand what I am doing in the background!

  4. Anonymous

    I agree - this is a great tutuorial.

    Do you have anything similar for SourceTree? I've read good things about and have it installed but I can't find any documenation to get me started (except the YouTube video which is more marketing focused)

    Thanks! 

    1. Glad  you like the tutorial. I'm sorry but we don't yet have one for Sourcetree. If you have Sourcetree open you should have the help installed. Help > Sourcetree Help that could help but not a tutorial of course.

  5. Anonymous

    Neatly explained. Thank you (smile)

  6. "Excellent" comment from Excellence, for Excellent tutorial and author.

  7. Anonymous

    Its clear for all levels of Developers..(smile) (smile)

  8. Anonymous

    Very VERY helpful tutorial, great way to get started and it covers the necessary basics.
    Would be nice to add also a windows version with the windows commands for people that don't know the equivalent. (smile)

    1. Glad you found the tutorial helpful! It always makes my day to hear that.  (big grin)  Can you help me understand your suggestion better? The commands on this page were all executed in a GitBash terminal on a Windows 64 system.  When you mean "windows version" do you mean some Windows client other than GitBash?  It is perfectly possible a new one was developed that I know nothing about and I love to test new client software.

      1. Anonymous

        I would have logged in with my BitBucket account, if I could have, but I won't create another account just so I can give a tip:

        You can simply hit the INSERT key in Git Bash to paste stuff. Should fit perfectly with all these no-mouse console-freaks (smile)

        1. Thanks, I have instructions on how to do that in Step 1.10 above. It is in an expand box if the reader needs some tips. Some users need those tips others don't.

  9. Anonymous

    thank you Mary!!!  Extremely helpful tutorial...

    1. Glad to help!  Have fun out there new Bitbuckian!

      1. Anonymous

        I'd have gone with "Bitbucketeer" (tongue)

        1. Trendy.  I guess I'm a classicist. (big grin)

  10. Anonymous

    I gotta agree with many other comments on this blog.

    This is an extremely well documented tutorial. It is "deceptively" simple and elegant. These publishing qualities demand a research, empathy and planning. Well done to you all.

    It's fun too!

    1. This made my morning. Thank you for the holiday gift! 

  11. Anonymous

    Wonderful tutor , Thanks 

     

    1. You are welcome!

  12. Anonymous

    thanks for taking the time to create this easy to follow tutorial!

    1. You are welcome!

  13. Anonymous

    This is one of the best documentation i have ever seen in my life

    1. I love this.  Course, I'm never going to convince anyone I didn't make the comment anonymously myself.  (tongue)(big grin)

  14. Anonymous

    I'm having trouble with the command 

    git add README

    on Mac OSX terminal.  I get the following error:

    fatal: Not a git repository (or any of the parent directories): .git

    1. You'll get this message if you issue a Git command in a file system location where you have not initialized a Git repository.   Make sure change directory to a repository or a subdirectory of a repository before issuing the command.

  15. I got a little stuck on Step 1 (10) "Paste the command you copied from Bitbucket onto the command line and press Return."

    I didn't know how to paste into git bash. I tired Ctrl + V, right clicking the black area of the window, but I found I had to right click the actual window for the little menu to come up where you can select Edit and then select Paste.

    Your tutorial is great, I just though mentioning something like this would help out.

    1. Hi Brian,

      Thanks for the feedback. I've tweaked that step to include a quick tip on GitBash editing. Let me know what you think.

      Mary

      1. You are awesome! Thank you so much for having this tutorial!

  16. Anonymous

    Hey, I had trouble with $ ls ~/repos

    fixed that when I did

    $ls ~/ repos

     

    I couldn't sign in because I signed up with my github, what's the trick?

  17. Anonymous

    Why mine is like this below and how to fix it? I even tried to rename my file from readme.txt to just readme (as your text editor seems that saved it to readme instead of readme.txt) but no chance.

     

    {\rtf1\ansi\ansicpg1252\cocoartf1138\cocoasubrtf510
    {\fonttbl\f0\fmodern\fcharset0 Courier;}
    {\colortbl;\red255\green255\blue255;}
    \paperw11900\paperh16840\margl1440\margr1440\vieww16200\viewh13200\viewkind0
    \deftab720
    \pard\pardeftab720
    
    \f0\fs24 \cf0 Welcome to My First Repo\
    -------------------------------\
    This repo is a practice repo I am using to learn Bitbucket.\
    }
    1. Hi,

      It appears you were working with Word or some other document editor.  Your editor added a number of control sequences such as:

      {\fonttbl\f0\fmodern\fcharset0 Courier;}
      

      You should use Notepad to edit text files.  Search for code or text editor on Windows.

      Mary

  18. Anonymous

    just wanted to say thanks for these great tutorials, keep up the good work!

  19. Anonymous

    I'm doing this in mercurial and am stuck on step 3.6: the "hg commit -m" command doesn't seem to work. How do I commit in mercurial?

    Great tutorial up to this point!

    1. Commit does not seems to work for me. See the below output from git bash

      ===================================================

      jansari@IN-CGT-JANSARI ~/repos/bb101repo-practice (master)
      $ git add readme

      jansari@IN-CGT-JANSARI ~/repos/bb101repo-practice (master)
      $ git commit -m "adding repo instructions"
      # On branch master
      #
      # Initial commit
      #
      # Untracked files:
      # (use "git add <file>..." to include in what will be committed)
      #
      # ReadMe
      nothing added to commit but untracked files present (use "git add" to track)

      jansari@IN-CGT-JANSARI ~/repos/bb101repo-practice (master)
      $

      ===============================================

      It is still saying that readme is a untracked file.

  20. Anonymous

    Could I suggest you add a note that Git Bash/Gui must be run with administrative rights in order to git clone to your User directory.

    The error given is Permission Denied(publickey) which can be very confusing.

    (At least in Windows 8)

    1. This looks like a SSH issue not a local permissions issue.  Did you choose to clone with SSH syntax instead of HTTP by chance?  I'll verify. I haven't tested with Windows 8 yet.

  21. Anonymous

    Under Step 3 I am a bit confused on how to get from step 2 to 3. Once the README file is created in Notepad, how do we get it into our repository is order to list it?

    1. You should create the file within the repository directory.  In Step3.1 you change into that directory.

  22. Anonymous

    Very good indeed.  Easy to follow.  Thanks.

  23. Anonymous

    Very useful! Thank you so much for taking the time to write this out and add very useful images. Will refer to all of these guides as needed,

  24. Thank's for your work. For  non-tech savvy people like me, in Step 3. where it says:

                         "2. Using your favorite editor, create a README file with the following content:"

    would be more comprehensible to say (or something similar):

                         "2. Using your favorite editor, create a README file with the following content and save the file into the folder

                               C:\Users\your_user_name\repos\bb101repo-practice

                                 where all this process are performed"

  25. Cuitlahuac,

    I've incorporated your suggestion into our instructions. Thank you for the suggestion!

    Mary

    1. This part is still confusing to me.  I have a file created on my local workstation.  I cannot find a local folder anywhere named the same as my repo (bb101repo-practice). Do I need to create this folder manually?  (I thought the clone process would have put something on my machine, but I'm not finding it.

      1. I thought I'd post an update to this, as it appears I might have reacted too early.  The repos folder did actually get created in my local environment, but to a mapped (home) drive on the network.  I found this by listing the files in the ~ folder in the terminal window and recognized where it was at that point.  So, it is wherever your home directory is configured.

        1. Glad you got it sorted!

  26. These are some really great tutorials thanks to the good use of images. I thought I was going to get lost for a second there and I noticed a handy image sitting below the point for me to follow (smile)

  27. Anonymous

    [user@centos myrepo]$ git clone https://username@bitbucket.org/atcm/myrepo.git .
    Initialized empty Git repository in /home/user/murepo/.git/
    error: Failed connect to bitbucket.org:443; Operation now in progress while accessing https://username@bitbucket.org/atcm/myrepo.git/info/refs
    fatal: HTTP request failed
    [user@centos myrepo]$

    the host is connected to the internet via proxy. when doing the same thig (git clone) from the machine in the same network - there is no problem. what am I doing wrong?

    1. Hmm, I'm not sure what is going on here.  Please file a report with support@bitbucket.org and our Support team will help you solve this.

    2. Anonymous

      Was your problem solved ?? I am also facing same problem. 

    3. Anonymous

      Just pass this command 
      git config  --global http.proxy http://10.3.100.211:8080

       

  28. Anonymous

    I see how to clone a git project. What if I want to grab a single file from the Downloads directory using curl or wget? The URL for a single file does not seem to be working no matter what user credentials I pass?

    1. You can use a curl call to GET a single source file like this:

      curl https://api.bitbucket.org/1.0/repositories/tutorials/tutorials.bitbucket.org/raw/default/index.html
  29. Sorry, don't want a source file, I want a file in my Downloads directory in my private repo. The URL that the browser reports is:

    https://bitbucket.org/jsolderitsch/bb101repo/downloads/SecureWebinarpdf.pdf

    What is the curl command for this?

    Thanks

    1. Unfortunately, we don't have a CURL for this. I've created a ticket for this: iIssue #6915

  30. I have some good news to report – this command works:

    curl -L -O "https://bitbucket.org/jsolderitsch/bb101repo/downloads/SecureWebinar.pdf" --user jsolderitsch

    BitBucket tech support suggested the -L option to curl.

    1. Thanks! Yes, I just saw this ticket in Support. You can download with this curl call but it isn't part of our REST API.  Many people want to POST files to the Downloads area and that is not supported. I'll tweak the ticket.

  31. I ran into issues while trying to clone into the newly created repo.

     

    I'm using OAuth from Google, so I did not setup a password for my account, and I am unable to clone via the SSH or HTTPS link. I might suggest a note for those using OAuth to determine what to do for that step.

    1. Hi Ian,

      Thanks for the suggestion. I'll add a note.

      Mary

      1. Anonymous

        Mr. Barton took the word right out of my... mind? I had the same problem and I agree this should be covered here.

         

  32. Mary, great tutorial and documentation! Thank you!  For an application to be successful and widely adopted it is important to make entry-points available for all levels of users and knowledge levels.  You are making great strides in this direction.

    I have some recommendations on how to improve this portion of your documentation from my perspective based upon what I was looking for and what would have helped me:

    •  I have used Git before intermittently, so I am a little weak on terminology and need something to help translate commands to "plainspeak." The title, "Clone Your Git Repo" was somewhat confusing because what I wanted to do was simply download the source from my repo locally so I could work on it on my computer.  After reading through the whole tutorial it is apparent to me that cloning a repository is how you get a "copy" of it, but adding a brief explanation at the beginning of the tutorial saying, "this is how you get a local copy of the repo to work on" would be really helpful.
    • Sorry if this one seems very obvious already... I would find it useful if, in the first paragraph, you would mention that this tutorial is based upon a brand new - empty - repo as if you were creating a new app from scratch, as I didn't come in at the start of the tutorial series.  Instead, I came to this page after copying over an existing (populated) repo from github and my goal was to download the project to my local machine so that I could work on it.  I was initially confused as to why Git would warn me that my repo was empty.  As I go back through the tutorial I see the sample repo comment for the README, "This repo is a practice repo I am using to learn Bitbucket," and it is a little more obvious, but adding a really quick explanation at the top of the tutorial would have helped me out.
    • I see another user has asked why they were getting Git error messages and you indicated it was because they probably had tried executing the command in a non Git initialized directory.  It would be helpful if you added a quick note in Step 1 where you run the clone command to copy the repo locally, stating that cloning automatically initializes that project directory with Git, similar to running the Git init command in a directory.

    Thank you so much and cheers!  This is great stuff.  If there is another tutorial that is more aligned with starting out having a project already populated (a new contributor to an existing repo, but trying to learn the basics of bb, Git, etc), please point me to it... maybe a good idea for additional documentation.

    Cheers!  Keep up the great work!

    1. David,

      Thank you so much for your comments and the compliments! I'll incorporate them as appropriate.  

      Just as an FYI, I delete the comments I incorporate to avoid confusing other readers.

      Mary

      1. Awesome!  Glad to help.  Another thing you do that is excellent is that you are very active in the community and in your responses, which in-turn helps drive up the value of your docs and products.

        I wondered if you had a tutorial specific to the idiosyncrasies of getting started as a new contributor to a Rails project... things like... do I still want to change the project folder name since the .rvmrc file is tied to the folder name (and therefore repo folder name)... does that make sense?  I can provide a specific example if it helps.

        My request is a little more in the line of specific Rails project help, but bb is a nature tie-in because that's where my repo sits.

        Anyhow... any thoughts, recommendations... is this something you all would handle or find value in offering?

        1. David,

          Thank you for that comment! My goal is to be the user advocate on the ground if you will.  I don't have a tutorial specific to Rails, this is the first time the topic has come up.  It might be good to start with a Rails tip page in our FAQ.  If you have an example or just a list of what you ran into, I can try and work one up.

          Mary

  33. Anonymous

    Hello,

    Thanks for this tutorial and free private repo service. I am facing clone problem. Can i discuss here? Thanks

    Regards
    Sohail

    1. Sohail,

      You can discuss it here. Or, you can send an email to support@bitbucket.org and get personal and often faster help.

      Mary

  34. Anonymous

    Hi Mary,

    Thanks for your wonderful tutorial. I am getting an error when i am trying to push the newly created REAME file to the server. Here are the commands that i typed and their output:

    Please tell me what went wrong. Thanks in advance (smile)

    1. Spencer,

      The first part is Git asking you to set a configuration value for the push.default value.  The best way to set this for a Git beginner is:

      Once you set that, try this again:

      Mary

      1. Anonymous

        Hi,

        I'm having the same problem, but it does not go away even I set push default value as you told to do. It still says:

        $ git push -u origin master

        fatal: 'origin' does not appear to be a git repository

        fatal: Could not read from remote repository.
         
        Please make sure you have the correct access rights
        and the repository exists.
        Can you advice me? Thanks!
  35. Anonymous

    Thank you Mary; these are all is so helpful!

  36. Anonymous

    Excellent tutorial, thanks for the clear explanations.

  37. Anonymous

    HI. in step two  you say:

     

    List the contents of your local repository – including the hidden files

    maybe a stupid question. but how do i do that?

    1. You can't learn unless you ask – it  is a learner's question. To list the files, you use the ls command.  To make sure you see hidden files, you use the -a flag.  So, at the command line in GitBash you type:

      ls -a

      And press enter.

  38. Anonymous

    "There are a several formats".. (smile)

    1. Dope slaps herself. Thanks for the catch!

  39. Anonymous

    This is a great tutorial. I'm a complete newbie to CVS and am so glad I found this!

    I'd like to make a suggestion, though.

    I got stuck on these lines:

    Open a browser and a terminal window on your local system (the system you code on). Then, do the following:

    1. Bring up the terminal window on your desktop and navigate to your home (~) directory.

    Yes, I'm a total newbie to CVSs, and frankly don't use the command prompt enough to have known right away that "terminal window" is referring to the Git Bash command line window that was installed earlier in the tutorial. The phrase "terminal window" wasn't mentioned earlier during installation of Git Bash (at least I don't think it was).

    Perhaps it would be helpful if a screenshot of the Git Bash window was added near the quoted lines.This would immediately show the reader what "terminal window" is referring to. (Or add "terminal window" to the instructions for installing Git Bash).

    This is really a minor point, I know, but it did trip me up for a bit until I tried entering the instruction's commands in Git Bash.

    Otherwise, awesome tutorial!!

    1. Love this comment because it shows how even very small inconsistencies in language can cause confusion.  I fight not to let them into my docs or any copy.  It is really hard though to explain to non-writers why it is important without showing examples of user comments like yours.  So, thank you.  

      I've called out terminal window in the intro sentence. Then, I'll drop in a screen cap as you request. Great comment!

       

      1. Anonymous

        I'm very glad I could help!

  40. Anonymous

    I'm stuck at step five. Here's my directory listing and the output of the "git status" command.

    Mark@MARKSLAPTOP-PC ~/repos/bb101repo-practice ((unknown))
    $ ls -al
    total 3
    drwxr-xr-x 4 Mark Administ 0 May 24 06:18 .
    drwxr-xr-x 1 Mark Administ 0 May 24 04:47 ..
    drwxr-xr-x 1 Mark Administ 4096 May 24 04:48 .git
    -rw-r--r-- 1 Mark Administ 123 May 24 06:18 README.txt
    Mark@MARKSLAPTOP-PC ~/repos/bb101repo-practice ((unknown))
    $ git status
    fatal: Not a git repository (or any of the parent directories): .git
    Mark@MARKSLAPTOP-PC ~/repos/bb101repo-practice ((unknown))
    $

    As you can see, the current directory is bb101repo-practice, so I don't understand why I'm getting that error. Does the problem have something to do with "((unknown))" after my current path?

    1. Mark,

      The problem does appear to be related to the (unknown).  I had never seen this before either.  So, I google for git bash unknown and found this on Stackoverflow:

      http://stackoverflow.com/questions/16120078/git-bash-always-says-the-branch-is-unknown-in-all-directories

      Try some of the solutions there...

      Mary

       

      1. Anonymous

        I created a new repo using the GUI and added the readme file from there. I then opened up the Command Line Git and there was no "((unknown))" after the new repo.

        I went through the commands in the SO link you provided, but nothing seemed to have any effect.

        If you're Googling for answers, then I'll assume I'm on my own in finding a resolution for this. I could continue to use both the GUI and the Command Line Gits, but I wasn't able to figure out how to push the new repo and its containing file to Bitbucket from the GUI interface, so I'd have to try to figure that out on my own anyway.

        Not an ideal situation in either case...

        1. You aren't on your own.  The first step should always be to google for answers.  There is a wide and deep pool of technical knowledge on the net. Getting an answer there is often quickest.  Googling hits our own Atlassian Answers database.  

          If you can't find a solution, you can file a ticket with our support@bitbucket.org. That is a good second step but may take longer as it puts you into a queue.  

          I'm sorry you are having problems. We will get you an answer. 

  41. Anonymous

    Thanks Mary... Its really helpful to me

  42. Anonymous

    BahtiyaR@BHTYR ~/repos/repos-c++ (master)
    $ git push -u origin master
    Password for 'https://bhtyr@bitbucket.org':
    error: src refspec master does not match any.
    error: failed to push some refs to 'https://bhtyr@bitbucket.org/bhtyr/repos.git'

    the error is caused by?

    1. It looks like the repository URL was bad.  

  43. Great tutorial, love the dumb-down language (tongue) because I can understand all this stuff, for the most part at least (smile).

    Question though [Platform: Win8 Pro]: When I make a local copy of a repo, it gets copied here c:\Users\myuser\repos\test-repo.

    Is there a way to change that folder path to anywhere else? I have a /clients folder in which I would like to copy my repos to.

    Thanks in advance.

    1. Ricardo,

      When you clone a repo, it is copied into the directory where you run the command.  IOW, if you want it in a different directory, change directory there and then enter the clone command.  Hope that makes sense.

      Mary

  44. Hello Mary,

    Yes, it makes sense. However, it's not intuitive when doing it via the Git Bash window because the commands are different from the CMD/PowerShell windows (DOS based commands). At least I wasn't able to make any sense of the commands of Git Bash explained in this tutorial, and although I'm not a hard core web programmer/developer, I'm a bit familiar with the old DOS commands and that made it SO MUCH easier.

    I learned this just these past couple of days.

    So yes, all I have to do is navigate to the folder I want to clone the repo to in the CMD/PowerShell prompt, run the "git clone reponame" command, then password and voila, repo cloned to the folder of my preference.

    Thanks for your help.

    1. Ricardo,

      Glad you solved it and thanks for the insight into your user experience.  The Git Bash window does look like a DOS window but really it uses Msysgit which is explained as:

      MSys is an environment for Windows offering a Unix-type shell and a Perl interpreter. Because many parts of Git are still not builtins programmed in C, but instead shell and Perl scripts, Git for Windows needs such an environment.

      This Stackoverflow page explains what you have discovered for yourself.  I'll see about explaining this a bit in the tut.

      Mary

      1. Anonymous

        A comment about this:  I'm pretty computer/command prompt savvy, but the ~ location tripped me up (I haven't used *nix seriously since college).  A little experimenting revealed that ~ is "C:\Users\<userName>" on my Windows 7 computer.  This typically isn't a folder users add files to directly. (They probably want ~/documents or some path straight off the C: drive.)  A note about what ~ is in windows would be useful for newbie users.

  45. Anonymous

    This tutorial is well written. Thank you.

     

  46. Anonymous

    Good tutorial! Thank you.

  47. Anonymous

    Hello, very nice tutorial, it makes this all very easy. However, I have a small problem.

    I don't seem to be able to fill in my password at step 1. Is this more occurent, and if so. How could I fix this?

    1. This is not typical. Keep in mind when you type in your Password, it won't be visible to you.  Can you supply any more information? What command line are you supplying? Does the command return any errors.

      1. Anonymous

        Mary, excellent work, also in replying to the comments/questions. 

          1. Anonymous

            hi mary... i simply faced the same problem with anon above where i cannot write my password as im typing and it refuse to appear ? did u get it? 

            1. Hi. Your password shouldn't appear at the command line when you type.  This is a security measure of most operating systems.  Is it happening someplace other than the command line?

    2. Anonymous

      Check firewall

  48. Anonymous

    thank's you have saved my time gud tutorial.

  49. Anonymous

    anything without great , clear and concise documentation leads to struggle for users.

    This is really well documented and awesome. Terrific job guys. 

  50. Anonymous

    The tutorial explains the process of setting up a bitbucket repo beautifully.You guys at Altassian rock.

  51. Anonymous

    I have to right-click (not left click) the GIT menu bar to get the menu drop down. Windows 7 64 bit.

  52. Hi Mary

    thanks for your great tutorial and all of your follow up comments

    I was following this tut using the terminal on my Mac and when it came to submitting the password I got this: "error: git-credential-osxkeychain died of signal 11". After checking around on the forums I see this is a common error, but I've yet to find a solution that works for me. I've been playing around with SourceTree also and I get the same error there.

    Do you have any suggestions how to get around this?

    cheers

    1. Roy,

      To enable HTTPS Credential Caching a.k.a 'password credential caching' for https  based interaction with Bitbucket, you need to download and install the "osxkeychain credential helper" and tell git to use it.   We have that documentation under Stash right now and you can follow the same instructions.  I'll have to update our Bitbucket docs within the next day or two.

      Mary 

      1. Hi Mary, thanks for your prompt reply.

        I'm afraid that, as I'm not an experienced terminal user, the document in Stash doesn't make too much sense to me. I'll have a search around and see if I can find some step by step instructions.

        cheers - roy

  53. Anonymous

    I get an error as below, when trying to clone. Wasn't able to do on IntelliJ, so tried with Cygwin with no luck:

    $ git clone https://myuser@bitbucket.org/myuser/test.git
    Cloning into 'test'...
    error: error setting certificate verify locations:
    CAfile: /usr/ssl/certs/ca-bundle.crt
    CApath: none while accessing https://myuser@bitbucket.org/myuser/test.git/info/refs
    fatal: HTTP request failed

     

    1. This tutorial assumes you are using GitBash.  I don't test against other clients.  That said, I did a search for this error and found this on Stackoverflow.

  54. Anonymous

    I have substituted my user name with myuser in above comment. (smile)

  55. I am getting an error while trying to clone from bitbucket repository via https:

    Using following command:

    git clone https://myuser@bitbucket.org/myrepo/myproject.git
    Cloning into 'myproject'...
    error: Connection time-out while accessing https://myuser@bitbucket.org/myrepo/
    myproject.git/info/refs?service=git-upload-pack
    fatal: HTTP request failed

     

    Please let me know what am i doing wrong?

    Thanks,

    Ashish Garg

  56. Ashish, you should send an email to support@bitbucket.org for this one.

  57. Anonymous

    how can I take a print out of this?

    File>Print Preview doesn't give the printable version. Is there any printable version of this document?

    Thanks

    1. I'm attaching the PDF I get with the File > Print dialog.  You don't say what browser you are using. I'm using Chrome which has a Save as PDF option.  Did you want the entire documentation set or just this page?Clone Your Git Repo and Add Source Files - Bitbucket - Atlassian Documentation.pdf

  58. Anonymous

    In  create README step, creating a file and saving it in repository is not mentioned properly. As I am a fresher, I found some difficulty over there. Otherwise it is really superb.

    1. Hi, thanks for the feedback. Can you be more specific about what you had trouble with?

      1. Anonymous

        In create README part, in step no 3, you have mentioned save the README file . But you haven't mentioned how to save i.e., command to save. There I found some difficulty.

        1. How you save would depend on what kind of client software you were using to create the file. Since, there are very many kinds of file editors, I can't be more specific; I assume you could read the documentation for your specific file editing software to learn how to Save.

  59. Anonymous

    Atlassian Team,

    This is really going great - hats off to you for writing such a clear step by step user guide. I am a new comer - and only because of crystal clear guidance here, I am able to use your platform effectively.

    I will be selfish if I don't mention this wonderful Tutorial by Lars Vogel which really cleared the concepts about DVCS in astonishingly simple language - thanks to him as well.

    I have few suggestions - hope you will consider.

    1. You (now) also have a wonderful product SourceTree with excellent GUI.Would you consider updating this user guide to that effect ? Many users would welcome this addition.
    2. I dont know if this is the right place to suggest something for SourceTree but since that product too belongs to your company, I am taking liberty to mention it here. Tortoise SVN has very useful shell extensions which really help to use their platform through windows explorer. Would you consider that for SourceTree as well ?

    Thanks once again for a wonderful product, platform and best of all, Documentation.

    Best Regards,

    AAD

    1. Glad to hear you like our tutorial and our product. Lars' tutorial on DVCS is very well done. We mention it to our users who are unfamiliar with DVCS.  Regarding your suggestions:

      1. Currently, we don't have plans to change the tutorial to use Sourcetree exclusively. Mostly because the rest of the documentation assumes you are using a command-line.  I'll bring it up with the team.
      2. I'm not sure if we have plans to support SVN with Sourctree. I'll ask and reply here.

      Thanks again for taking the time to comment.  We really appreciate our active community.

  60. Anonymous

    Thanks for your reply.


    >>Currently, we don't have plans to change the tutorial to use Sourcetree exclusively. Mostly because the rest of the documentation assumes you are using a command-line.  I'll bring it up with the team.

    I understand - this is a huge task. But at least you can mention somewhere in 'BitBucket 101' that such a GUI tool is available. I started searching for GUI tool after seeing the terminal screen in your first tutorial (smile)

    >>I'm not sure if we have plans to support SVN with Sourctree. I'll ask and reply here.

    Did I fail to convey my point ? I did not expect SourceTree to support SVN. But I wished if SourceTree can have Shell Extensions SIMILAR TO SVN - so that most of the job can be done even without opening SourceTree. Of course I am not sure if SourceTree Developers would like this idea AFTER developing a nice GUI.

     

    Best Regards,

    AAD

    1. Anonymous

      >>I understand - this is a huge task. But at least you can mention somewhere in 'BitBucket 101' that such a GUI tool is available. I started searching for GUI tool after seeing the terminal screen in your first tutorial (smile)

      Please ignore. I can see that it already existed in your 101. Sorry for inconvenience.

       

      Regards,

      AAD

  61. Anonymous

    Clear, concise tutorial.

  62. Anonymous

    Awesome tutorial, straight-forward! Thanks!

  63. Anonymous

    I have created local directory repos and when I tried to see in my file system...it is showing me the repos is created in h drive (network drive). When I do pwd in GIt bash it is showing me as /h

    Is this expected behavior. Is my local repository in the network drive not in the c drive?

    1. You can put GitBash or your repos in any drive accessible to you.  The C  is the standard drive for most setups so that is what we show in our examples.

      1. Anonymous

        I did not do any changes in my installation or setup. I expected GitBash will create repos directory in my c drive...but it created in network drive. I never accessed this h drive(network drive) earlier in my daily work.

        1. It is possible for your Windows administrator to specify a default directory for installing new Windows programs.  That might be the situation in your case. If you are concerned, you can talk to your system administrator about this.  

  64. Anonymous

    I get an error as below, when trying to clone. why and how to solve

    Administrator@20130814-2319 /c/repos $ git clone git@bitbucket.org:Edward_Wu/bb101repo.git

    Cloning into 'bb101repo'...

    Permission denied (publickey).

    fatal: Could not read from remote repository.

    Please make sure you have the correct access rights and the repository exists.

     

    Thanks,

    1. Your clone should use an http URL at this point. It would look like this:

      $ git clone https://newuserme@bitbucket.org/newuserme/bb101repo.git bb101repo-practice

      If you want to skip ahead and use SSH, you can but make sure you have set up your SSH key and imported it into Bitbucket.

    2. Anonymous

      I had the same problem.  I verified the address as Edward_Wu suggested, but still did not have any luck.

      It turned out that I had created a public key back on my first attempt to go through the tutorials.   I went in and deleted that key since I no longer use that computer.  I went back to the "Clone" button and re-copied the URL.   It worked that time.

  65. I've been having many problems with this unfortunately, on my home computer it works fine however at work I'm having problems.

    When trying to clone I get the following:

    fatal: unable to access 'https://reponame@bitbucket.org/reponame/lwqa.gi
    t/': Failed connect to bitbucket.org:443; No error

    I'm not behind a proxy/blocked firewall and can access HTTPS sites normally.

    1. The call was attempting to connect through port 443 but failed.  It could be the port is blocked for some reason. Did you talk to your system administrator? You can also try SSH access to see if that helps.  If you try both of those solutions and still have problems, file a support ticket.

  66. Anonymous

    Just wanted to post that these directions are phenomenal.  I'm a sysadmin who'd learning a bit of coding/version management/etc.  This is incredibly helpful and I'm looking forward to utilizing the heck out of git/bitbucket. (smile)

    1. Hey thanks! You made my day.  

  67. Anonymous

    Hi,

       Thank you for posting this nice tutorial. When I tried to push the commits I got the below error:

    $ git push -u master
    warning: push.default is unset; its implicit value is changing in Git 2.0 from 'matching' to 'upstream'. To squelch this message and maintain the current behavior after the default changes, use:

    git config --global push.default matching

    To squelch this message and adopt the new behavior now, use:

    git config --global push.default upstream

    See 'git help config' and search for 'push.default' for further information.

    fatal: 'master' does not appear to be a git repository
    fatal: The remote end hung up unexpectedly

    so I issued the below command

     git config --global push.default upstream

    but now I am receving the following message

    $ git push -u master
    fatal: 'master' does not appear to be a git repository
    fatal: The remote end hung up unexpectedly

    What did I miss? (smile)

    1. Anonymous

      gosh! its embarrassing

      the correct command is

      $ git push -u origin master

      just noticed after posting the above comment, sorry!

  68. Anonymous

    Hi, Is there a way I can write a dos script to pull my "Bit bucket Branch" into my local machine. I need to automate a script which will pull on daily basis before I start writing in my branch.

    1. Yes,  you can write a batch file that does this for you. Then, use the Windows scheduler to run the batch file regularly.  Stack Overflow has a lot of queries about this:

      http://stackoverflow.com/questions/5401229/how-do-i-execute-several-git-commands-in-a-batch-file-without-terminating-after

  69. Anonymous

    You need to explain what you are doing when you "clone" your repository to the local system and how this relates to checking out a local copy of the repositlyr (for those familiar with other version control software). Is it the same thing?

    1. Cloning is not the same as a "check out" in other version control software.  With Git you are always cloning the entire repository. With other version control systems, you can checkout just a single directory.

      This documentation does not compare and contrast version control systems. Lots of folks have already done this. Often, very heated and "religious" discussions spring up.  Since the goal of this documentation is to teach you about Bitbucket and many of our readers already know DVCS, I don't do a lot of compare and contrast here.

  70. Anonymous

    I do not understand where I am supposed to save the readme file in the tutorial!

    1. You should save it to the root folder of your local tutorial directory.

  71. Anonymous

    Hi, everybody. I've some problem like this:

    error: SSL certificate problem, verify that the CA cert is OK. Details:
    error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed while accessing https://nurdus@bitbucket.org/nurdusteam_eties/lux.git/info/refs

    fatal: HTTP request failed

     

    What do you think about it?

    Best regard!

  72. Anonymous

    Doesn't let me type on the password bit :/

    1. Really? What step were you on?

  73. Anonymous

    manthony, thanks. I'll try to do.

  74. Anonymous

    I did it thank you very mush (Y) 

  75. I'm getting stuck on the clone step. I'm getting the following:

    $ git clone https://<my info>

    Cloning into 'bb101repo'...

    fatal: could not read Password for 'https://<my info>@bitbucket.org': No such file or directory

     

    Any ideas on what the problem could be? I just opened my account today.


    1. A few things to try:

      • Check and be sure that you successfully created the directory for the repository in the second step of the clone process by navigating to the Repos folder if it does not exist try the mkdir repos command again.
      • Be sure you switched directories to your repo by entering cd repos before you paste the clone command.
      • Check the password and make sure it is the same as the password is the same one you created in Bitbucket.

      If none of those things work try contacting support@bitbucket.org to see if they can help you resolve the problem.

  76. Thanks for the tutorial, I'm finding it very useful. I've had a few issues, but a quick search sorts that. Will post anything I find that may help.

     

    Just as a help to anyone else having trouble trying to clone into their repo folder, I found that you have to edit the command to include your password as follows:

    git clone https://username@bitbucket.org/username/bb101repo.git

    has to be changed to

    git clone https://username:password@bitbucket.org/username/bb101repo.git

     

    I kept getting the following command, not sure what the reason was, but adding the password fixes it.

    fatal: could not read Password for 'https://mikepokeeffe@bitbucket.org': No such
    file or directory

    1. Anonymous

      Thank you! This worked.

    2. I too had the same problem and adding the password into the url, as Mike suggests, solved the problem.

      I'm curious why this is the case though.  Why didn't it prompt for the password as the documentation suggests?

       

    3. Anonymous

      Thank you! this worked perfect!

  77. Anonymous

    Great tutorial! Thanks very much.

    But my first "git push" failed and I had to submit git config --global push.default simple first. (Or should I have used "... default upstream" instead?

    Then I got this error: "error: src refspec master does not match any."

    I found this solution on stackoverflow:use this one-off command: git commit -m 'initial commit'.

    Maybe this is all because of recent updates in git?

    1. Thank you! I am going to look into adding this step to the tutorial as I see others have experienced the same challenge. 

  78. Anonymous

    Hello! I`ve bumped into a problem while trying to clone repository to my local drive (end of step 1), after I send a command to clone, instead of password prompt I got an error, here is gitBash log:

     

    Lena@ORBRY /d/Alex

    $ mkdir bb_repos

    Lena@ORBRY /d/Alex

    $ cd bb_repos/

    Lena@ORBRY /d/Alex/bb_repos

    $ git clone https://Orbry@bitbucket.org/Orbry/bb101repo.git
    Cloning into 'bb101repo'...
    fatal: could not read Password for 'https://Orbry@bitbucket.org': No such file or directory

     

    So far I`ve completed all the steps, confirmed email, and everything was fine. What could be the cause of the problem?

    1. Anonymous

      The problem is solved, you have to supply a password initially:

      git clone https://user

      (tongue)

      assword

       

      and if you have some special symbols in username or password, you have to URL encode them

    2. Thank you for taking the time to comment. I'm glad you found a solution to the error message. I'm going to be going back through this portion of the tutorial and making some updates as I see you are not the first to experience this issue.

  79. Anonymous

    60 mins for walking the tutorial? - never!

    after 15 mins, i was almost done with the git part, but failed (while following the instructions).

    Then i needed to search and try... until i found [this].

    Took me an hour just to complete the first half... (sad)

    What a time waste having to run after a solution instead of grasping the whole picture.

    One unhappy customer.

    And while we're at it: is it correct, the whatever i develop using bitbucket "belongs" to atlassian? I've had that in the past (people stealing my code/effort/ideas). The terms of service seam to be biased towards one company (if i understand them correctly... not a native...)

    Well, so better stop wasting resources NOW, when it wont hurt too much yet.

    Bye

    1. Hello I'm sorry you had a disappointing experience with the tutorial. We are always working to improve it, it is currently designed to go through the complete process of setting up git, a repository on your local system, configuring your git set up, and cloning the repository all using the command line interface. This takes time and effort but it's the most complete way to establish a git presence which you can later modify and use in any way you choose. 

      Soon we will be putting together a tutorial which follows the "fast path" to getting git set up and running using our SourceTree GUI.

  80. when i have done with creating my repository and created a directory in my system...i have executed the command...

    git clone https://xyz@bitbucket.org/xyz05/xyz101repo.git

    cloning into xyz101repo

    fatal : could not read password for the  'link' :No such file or directory

    what to do now..? how to resolve this one ..? can annyone suggest me

    1. I have tried some few solutions from above....comments...but i failed in dat tooo....it is shwoing..authentication failed for the url

  81. Anonymous

    Hello everybody,

    I'm following the tutorial and I'm struck in the step referred to cloning the empty repo, it just doesn't ask me for the password and directly get the following error: "fatal: could not read Password for..."

    Could you give me hand??


    Thanks!

    1. Anonymous

      Having the same problem..

  82. Mary,

    Excellent tutorial. Would it be possible to do a tutorial using TortoiseGit or a Windows integrated tool. I found your tutorial for the Mercurial part a lot easier to follow and I believe it is the TortoiseHg that made it easier.

    Thanks again for putting the time and effort to help us get started.

    Regards,

    Fab

    1. Glad you enjoyed the tutorial! I am the new writer for these documents and am in the early stages of creating a branch of this tutorial which would be based on SourceTree (Atlassian's GUI based Git Source control) and Git in both Windows and Mac.

      I hope I can continue to keep this tutorial in the awesome shape in which Mary left it to me.

  83. Anonymous

    Hi, despite a couple of false starts, I got everything in this tutorial done. But say I want to change my readme file. I edited it. I thought should be able to say

    git commit -m "change to readme"

    then

    git push -u origin master

    to see the change in bitbucket. But I had to re-add the file first. So do I have to enter three commands every time I change a file: add, push, commit?
    BTW,  when I read things like "Go back ... and push your committed changes using the git push command" I immediately enter "git push" right then without waiting to read further, then I see that there is more to the command. Maybe there is a better wording, such as leaving the git out of it, that forces me to keep reading.

  84. The clone url I copy from the Bitbucket dashboard is not a git one (hg clone https://me@bitbucket.org/me/reponame), but I have seen other comments saying to modify it.

    Trying what I think makes sense doesn't work:

    $ git clone https://me@bitbucket.org/me/reponame
    Cloning into 'reponame'...
    fatal: repository 'https://me@bitbucket.org/me/reponame/' not found
    $ git clone https://me@bitbucket.org/me/reponame.git
    Cloning into 'reponame'...
    fatal: repository 'https://me@bitbucket.org/me/reponame.git not found

    I've tried ssh (uploaded my public key), and http.

    What am I missing? I use git every day, so I feel pretty silly about now.



    1. Ok, new to mercurial. I had forked a mercurial repository, and that's why the git command wasn't working. Silly, indeed.

      1. Hey Christy,

        Sorry I didn't get to your question yesterday. I did the same thing about a week ago and I wrote this tutorial (smile).

        Happy coding,

        Dan