Skip to end of metadata
Go to start of metadata

If you are new to hosting your code, code management with distributed version control systems (DVCS), or Git, this Bitbucket tutorial gives you a taste of developing with DVCS and Git using branches. In this tutorial, you'll install Git for your operating system, create and clone a repository, push and pull changes, and finally create and merge a branch. Throughout, you'll use the hosted code management system that is Bitbucket.

The tutorial consists of the following pages:

How to work through the tutorial

If you are totally new to DVCS and/or Bitbucket, you should work through each page sequentially as each new page builds on the material from the previous pages.  If you prefer to learn the tools before working through this tutorial, you can learn more about Git here.

At the end of each page is a Next section directs you to the next tutorial page. If you get lost you can use the navigation bar (to your left) to locate the next page. If you feel confident skipping pages or just going to the pages you need, feel free to do that too.

Start the tutorial with Set up Git.

 

If you want to skip the tutorial all together, You might be interested in:

42 Comments

    1. Anonymous

      Great Tutorial Lars, Thanks for sharing.

  1. Anonymous

    Good tutorial. Makes it easy to use bitbucket. Thanks!

    1. Thank you! Always glad to hear this kind of comment. (big grin)

  2. Anonymous

  3. very good tutorial, I am switching from github and enjoying bitbucket and this tutorial. Very smooth and clean wording really amazing way. Thanks for producing such a detailed and easy tutorial specially for beginners.

  4. Anonymous

    Great tutorial, I spent a lot of time on it, but got pretty confused as my boss has me learning Mercurial and Bitbucket... learning git only confused me. One of the pages says something to the effect if you want to learn Mercurial with it (other than a few nods at Mercurial), "you're on your own."

    Would you consider having an alternate tutorial for Mercurial on it's own. For me, time is money and I wasted a bunch of time on Git.

    Otherwise, I am very impressed by the overall tutorial. Thanks for that!

    Kevin

    1. Kevin,

      We have talked about having two tutorials yes.  We aren't planning one for the near future.  There are many more things you can do with Mercurial and with Git than our covered by our tutorial – which is really teaching users about bitbucket and not any particular DVCS.  We often talk about expanding and creating tutorials with more in depth material about Git commands and process — or Mercurial commands and processes . Would you have liked this as well?

      Mary

  5. Anonymous

    So I can go throught 101 for Mercurial?  I do not want to download, use, learn Git. Just Mercurial.
    Or do I have to go to the Mercurial site?lket

     

    1. Hi,

      This tutorial is for Bitbucket's features and how to use them. Since Bitbucket supports both Git and Mercurial, the tutorial has you getting a taste of both.  The guide isn't intended to be a tutorial for Mercurial or Git as DVCS packages. If you want to learn the ins and outs of Mercurial, yes, you should use the tutorial the makers of Mercurial recommend.

      Cheers,

      Mary

  6. I've imported a GitHub project into BitBucket. Since then, the GitHub project has received changes. What's the easiest way to import the GitHub changes into the BitBucket version?

    1. The easiest way just depends on how big a change.  One or two files, you could just clone the Bitbucket version and make the change manually.  If you expect to try an maintain these both simultaneously, you should investigate using push hooks or some other automation feature to keep them in sync.

  7. Thanks for the quick response! Yeah, I guess those are standard options for importing changes. I hear talk of BitBucket adding a feature similar to Import, where BitBucket can from the web browser import changes from the original repository. That would be cool!

  8. Anonymous

    Something that would be very helpful in this documentation is a list of terms and definitions (i.e. Repo, Fork, Pull Request, SSH for Git, etc.).  I'd include a brief explanation of what each term means/is and how it's used in relation to other tools and Bitbucket.  This dictionary would be very helpful for developers moving from Microsoft products or even SVN.

    1. Thank you for the suggestion.  I weigh the pros and cons of this a lot; a brief explanation is some times not possible – in particular if I'm comparing and contrasting tools.  So, I'm not sure I want to put that into the tutorial. Glossaries don't typically get a lot of users; but maybe I can pitch another way that would draw more users.

  9. Anonymous

    I have a team account.

    And here is the problem: how to check previous version of my source code after one member of my team has made some changes and merged them?

    thank you!!!

    1. Hi,

      I need more information. By "check" do you mean review the changes, test the changes, or something else? 

      Mary

      1. Anonymous

        use

        ( updating own repository )

        git pull origin master   

        ( push own locally changes to git repository )

        ( command )  (first commit then push)

        git commit -a -m "add changes"

        git push origin master

        1. The easiest way to do this is for you and your team mates each to work in branches.  That way, you don't pull his code directly into yours.  You can learn some basics workflows here: http://www.atlassian.com/git/workflows

          1. Anonymous

            what do you means ? ( That way, you don't pull his code directly into yours.)

            1. When you work on a repository, you are always working on a branch. To see which branch you are on use the git status command.  

              If you pull another user's changes directly into your working branch, git attempts to merge for you. Depending on what you are doing, you might not want to run the risk of clobbering your current work.   

              Git Branching is a great resource on this topic.

  10. Can I create a 'bare' Git repository?  I tried to ssh via command line to bitbucket to do this, but it is not allowed.

    1. You can create an empty repo on Bitbucket and clone it, yes. Did I understand your question?

      1. Thanks for the reply!  Actually, can I ssh into my repo on BitBucket and use the command line there?

      2. Now I realize 'ssh' login is NOT allowed.  I'm trying to create a 'bare' repo of an existing production website.

         

        Is it correct that by using:

        > git remote add origin ssh://git@bitbucket.org/username/project.git

        this will create a 'bare' repo?

         

        Thank you!

        1. Guy,

          Correct, you cannot ssh directly to Bitbucket and use a command line.  Also, you can't create a repo on Bitbucket with a git command.  You can do it with a REST call.

          https://api.bitbucket.org/1.0/repositories  --data "name=mynewrepo"

          See the repository Resource for more information on this.

          Mary

      3. Anonymous

        There is a difference between a repo and a bare repo. How do you create a bare repro?

        1. Yes, a bare repo doesn't contain a working code tree. A bare repo is contains only the contents of the .git subdirectory.   You can't create one on Bitbucket. You can only create them on your local machine. To create one, you supply the --bare flag when you clone.

          git clone --bare repository_url

          This net resource has more information on them: http://gitolite.com/concepts/bare.html

  11. Anonymous

    گنج تو وجودت است؛ جای دیگر به دنبالش نگرد! همه قصر ها و همه ی پل هایی که به قصر ختم میشوند مهمل و بی معنی اند، تو باید پل خود را در درون وجود خود خلق کنی! قصر آنجاست؛ گنج هم آنجاست...

  12. Anonymous

    嗯 ,很好!

  13. Anonymous

  14. Anonymous

    In case you haven't noticed already, the link to the Max OSX version of SourceTree incorrectly links to the Windows version.

    1. Nope, I hadn't noticed. Thanks for the catch. (wink)

  15. Anonymous

    Great idea but hopelessly difficult site to use. How can any busy author wish to spend time learning all these technicalities? Please create a user friendly site!!!

    1. Hi, I'm sorry to hear you weren't satisfied with the site. Developing code is a technical task so, while Bitbucket does strive to make things as easy as possible, it would be unlikely we could eliminate the need to learn for everyone.  If you could provide more information about what you found too technical, we might be able to help you further.

  16. Anonymous

    I know the effort this documentation represents.

    You could add "Probably need to install xclip" in the SSH part.

    And a setp-by-step tutorial. No explanations, no theory. Just do it.

    The bad part was that this can be put to work without GitBash. Never find in LinuxMint or in any other tutorial. Let's hope it's automatic or just for Windows.

    Any way, without your work, I could not do it. Thanks.

     

  17. Anonymous

    Dear sir,

    I have already create the account in the bit bucket and already i have installesd the source tree in our computer..I want to try add the some source code through the source tree.it's easily add in the source tree..after that when i want to view the same code through the bit bucket then it's not possible..sir please help me to access the code through bit bucket account..

  18. Anonymous

    Hi guy, thank you for your sharing. I got a problem when i clone a project from bitbucket with following your step. When I use command 'git clone URL', it will have 'connection time-out' error message after a while. So can you help me fix it. thanks.

  19. Anonymous

    Want to try bucket-o-sand

    Login, clone, Copy the https command, run it on local Linux,  but git the error: how to work around?

    git clone https://bitbucket.org/tutorials/bucket-o-sand.git
    Initialized empty Git repository in /home/admdtsp1/git/projects/bucket-o-sand/.git/
    error: Couldn't resolve host 'bitbucket.org' while accessing https://bitbucket.org/tutorials/bucket-o-sand.git/info/refs

    fatal: HTTP request failed

     

     

    1. It's hard to tell exactly why our getting the fail message. I'm looking at the command you have listed and wonder if you are missing the user name shown in bold in the following example:

      git clone https://yourusername@bitbucket.org/tutorials/bucket-o-sand.git

      Other wise you can contact support through: https://bitbucket.org/support