• Using BitBucket for Source Control


    If you are a professional software developer, chances are you have various source code projects on your hard drive. You have those backed up, right? Nowadays, with SkyDrive and GoogleDrive, and DropBox fighting over who gets to hang onto your files, you do have options. However, if you want to actually truly outsource your source control repository, bug tracking, and documentation, you have option for that too – it’s www.bitbucket.org

    BitBucket (as of this writing) allows unlimited private repositories, with up to 5 people that you can share those private repositories with. For me, that is a pretty sweet deal! To get this going, here is what you need to do:

    Step 1: Install Git for Visual Studio 2010

    Go into Extension Manager in Visual Studio:

    then click Online Gallery and search for “GIT”:

    from what I gather, you need both of these items. The Git Extensions installs all the command-line stuff and the Git Source Control Provider ties in “some” of the Visual Studio stuff, but doesn’t seem to work correctly for me.

    Step 2: Set up a BitBucket account

    Navigate to https://bitbucket.org/ and sign-up, it’s free. Once logged in, you will have some options for creating your first repository.

    Step 3: Create a repository on BitBucket

    The menu navigation is pretty simple – go into the screen that let’s you create a new repository (https://bitbucket.org/repo/create as of this writing). From here, you chose the name (which I make the same as my solution name), mark it as Private, I choose Git for the type, and I also like to turn on Issue Tracking and Wiki in case I need them. I might have something like this:

    OK, so now we have Git installed locally and we have a repository up on BitBucket.

    Step 4: Wire up your local repository to the remote one

    Open up a command line. Navigate to a root directory where you want all of your BitBucket projects – I chose C:\_BitBucket. This will be your local repository. In this local stream, you will make all your changes. At some point, you can then commit those changes and “push” them up to bit bucket.

    Before we do that, we have to associate that BitBucket repository with our local directory. So, from that root directory (don’t create a directory for this project), run the command that it tells you on the main repository page of your project, for example:

    git clone https://MyUserName@bitbucket.org/MyUserName/sedersoftware.sampleproject.git

    You should see something like this:

    C:\_BitBucket>git clone https://MyUserName@bitbucket.org/MyUserName/sedersoftware.sa
    mpleproject.git
    Cloning into sedersoftware.sampleproject…
    Password:
    warning: You appear to have cloned an empty repository.

    C:\_BitBucket>

    This is true, you did clone an empty repository. So, under that C:\_BitBucket directory, you should now have a sedersoftware.sampleproject. Under that, you probably want to add a \bin, \docs, and \src – and under \src is where you would create your solution.

    Step 5: Create or copy your solution to your local repository

    If you already have source, simply copy it into C:\_BitBucket\sedersoftware.sampleproject\src\ – or use Visual Studio to create a new project there:

    Either way, get your source to that directory.

    Step 6: Add files to your local repository

    Now, we need to “add” these files to the local repository. Now, you might have luck using that Git plug-in for visual studio, but I couldn’t get it working. The good news is, the syntax is pretty easy from the command-line. Here’s what I do from the C:\_BitBucket\sedersoftware.sampleproject directory:

    Just a ‘git add .’ and ‘git commit –m “Added files”‘ – that adds these files to the local repository. Now, we have to push them up to BitBucket

    Step 7: Push your local repository up to BitBucket

    At this point, your project is “checked in” to your local repository, sitting on your hard drive. We now need “push” these files up to BitBucket. To do that, we need to a one-time step, to make these pushes easier. Let’s create an alias for the full URL of our project.

    git remote add myProject https://MyBBUser@bitbucket.org/MyBBUser/sedersoftware.sampleproject.git

    this will create an alias called “myProject” that points to that big URL. You get that URL from the main page of your repository, on www.bitbucket.org.

    you then type:

    git push -u myProject master

    where “myProject” is the alias we created a minute ago and the “master” is the default name of our branch. This command prompts you for your bitbucket password, and it will push your files up:

    and sure enough, on BitBucket, I can my push – AND all my source files are up there now too:

    Step 8: Updates from now on…

    The good news is, from this point on – making updates is a bit easier. Let’s say you’ve modified some files, you’ve added some files and now you are ready to save everything. You need to do a “git add .” to add any new files to the local repository, you need to do a “git commit” with a comment to “check the changes in” – then just a simple “git push” – will push to the same place you pushed last time. It will prompt you for a password, but aside from that, this just works nice and simple.

    So, open a command-line, navigate into the project directory (e.g. C:\_BitBucket\SederSoftware.SampleProject) and type:

    • git add .
    • git commit –m “Commit message goes here”
    • git push

    And that’s it! There is of course much more to Git – including “ignoring” certain files for example. You can explore that on your own. In the meantime, this will get your source off of your hard drive and into an offsite (and free) source code repository.

  • 相关阅读:
    SASS常用方法
    Vue 全局过滤和局部过滤
    Java进阶知识点8:高可扩展架构的利器
    InnoDB MVCC RR隔离级别下的数据可见性总结
    记一次诡异的网络故障排除
    数据库的读锁和写锁在业务上的应用场景总结
    Gradle配置IDEA正常识别JPA Metamodel Generator动态生成的代码
    程序员容易读错的单词
    Java进阶知识点7:不要只会写synchronized
    Java进阶知识点6:并发容器背后的设计理念
  • 原文地址:https://www.cnblogs.com/wmlunge/p/2670546.html
Copyright © 2020-2023  润新知