Source code hosting site BitBucket

BitBucket is a source code hosting website that uses Mercurial and Git as a distributed version control system, while providing business plans and free accounts.

I'm working on a private project recently and I want to find a more reliable private version control tool. At the beginning, I thought of github, but when I thought about the private projects on github, there was a charge, and I gave up. Finally decided to use BitBucket.

BitBucket is similar to github and gitee, and its performance is also very good. The main thing is that it provides 1G of free space. This is most suitable for private projects like mine. This article describes how to get started using BitBucket for git version management.

1. First register BitBucket users (may need to over the wall).

Through this registered address: https://bitbucket.org/ , you can register your personal account of BitBucket. Register to use the mailbox and need to be verified.

2. User interface introduction

This is how bitbucket starts after logging in:

 

Screenshot.png

To be reasonable, I think this interface is not much worse than github.
BitBucket uses English by default, and it is fine for students who are not very good in English. You can set it to Chinese interface in Settings-> Language. (A snicker, really friendly).

 

![

Screenshot png

 

Screenshot png

 

Screenshot.png

Back to the main interface, see the menu on the left. For personal projects, there are several categories: overview, project, warehouse, pull request, clip, and problem.

 

Screenshot 2017-12-11 8.28.18 pm.png

  • Overview

    Here we will show all the relevant warehouses and panels in the personal account.

  • warehouse

    Not much to say, everyone understands.

  • project

    All personal participation projects are shown here. The project needs a team to create.

  • Pull request

    Other people can pull your project, but you need to get your permission.

  • problem

    Problems like conflicts.

  • Snippet

    We can store part of the code in bitbucket in the form of fragments.

3. Create a personal remote warehouse and link to the local warehouse

  • Creating a personal remote warehouse A
    warehouse needs to be created by individuals or teams. Rely on individuals by default.

     

    Screenshot png

     

    When creating a warehouse, we can choose the owner of the warehouse. And can specify whether it is a private warehouse. You can also specify the version control system to use. The default bitbuket supports Git. In the advanced settings, you can also see some other features, such as: select the code language of the warehouse storage. Here I created an H5 code warehouse test.

     

    Screenshot png

Before using the warehouse, we must first open the warehouse. bitbucket provides two main ways to get started: easy entry and command line entry.
In Easy Getting Started, we can create a README file to describe this repository, or use a gitignore file to ignore the control of the file.
In the command line primer. We can use an existing warehouse to create, of course, you can also use an empty project to create.
It is generally recommended to use a README file directly to open it here. After creating, you can use this warehouse. We can also invite others to read and write to this warehouse.

 

Screenshot png

 

In the box in the figure, it is the warehouse address of this warehouse in BitBucket. When we created the remote warehouse, we used this address.

  • Creating a local warehouse mapped to a remote warehouse
    There are two ways to map a remote warehouse to a local warehouse.
    <1> Check out directly from BitBucket's warehouse.
    In BitBucket's warehouse, we can directly find the warehouse checkout options:

     

    Check out

     

    Screenshot png

     

    Open the local folder. I see one more .git file and one README file in the file (this was created when we opened the remote warehouse). This indicates that the mapping relationship has been established.
    We might as well open SourceTree (this is a visual git interface operation tool) to check it out.

     


    Here you can see that the test warehouse is already in the local warehouse.

    Screenshot.png


    Select a suitable local folder after checking out, and there is already a mapping relationship with this remote warehouse.

<2> First create a local warehouse, and then push the contents of the local warehouse to the remote warehouse.
A newly created local folder can be used as a local warehouse. Similarly, using an existing project can also be used as a local warehouse. Below I will use an existing project as a local warehouse example. For example, use one of my folders demoas a local repository.

Screenshot.png


Before using, we first open SourceTree (this is a visual git interface operation tool)

Screenshot.png


There are two local warehouses on the interface. We clicked New and saw that there are several different options. The basic meaning will be understood, we choose to use添加已经存在的本地仓库

Screen shot 2017-12-12 8.58.33.png


This will bring up a folder selector. We only need to select the previous demo to create this local warehouse, and at the same time we can select the remote warehouse. At this time, we only need to select the corresponding account.

 

 

Looking at the remote warehouse again, a demo warehouse has appeared. At this time, both local and remote warehouses are completed.

 

4. Create a team and add a project

Click the plus sign on the left:

 

Screenshot.png

 

 

 

Choose a team:

After the team is successful, there will be an interface:

 

 

We can create warehouses directly in the team, and also create projects.

There are currently no projects in this team, we can create new ones.

 


After the project is created, we can add the warehouse to the project.

 

 

So we created a team project.

5. Add members to the team and set the permissions of the members

 

 

In the main interface of BitBucket, we can choose different teams to operate.

 

Here we choose the team we just created-MyTestDemoTeam. That is, we entered the team.

Select a member, you can see that there is only one member of myself.
Click Member Management in the upper right corner to enter the member management interface. Here we can add other members or other teams.


Click to add members:


Here you can set the identity of the member-manager or developer.
I set Tom as a developer here, which means that he does not have the authority to manage this team. But the code can be checked out and submitted.
Finally, back to the member interface:


We see Tom here, indicating that the addition was successful.
Next, we enter the team management interface:
we see that there are two user groups, namely Administratorsand Developers. These are the two default user groups. Before that, I added Tom to the Developersuser group.
We can also add other user groups ourselves.


How to add is actually very simple. Those who are interested can try it.
If you want to delete a user group, just click the small X button on the right side of the user group.

 

Now we first enter the Developersuser group and see how to set the permissions of the user group:


Here will intuitively show the permissions that the user group has, for example, the current Developersuser has the permission to create a warehouse and the default write. We enter the editing interface to change the permissions of the user group:

 


Here is to set the user's permissions. After setting the permissions of the user group, all members (such as Tom) included in the user group will be restricted by the user's permissions.

 

6. The actual development and use of BitBucket

After configuring these functions, you can use BitBucket for version control. BitBucket contains the most basic functions of commit, push, branch processing, merge branch and so on.

  • submit

We demonstrate it in SourceTree.
In a local warehouse demo that we have created before, we use SourceTree to visually control it:

 

When we don't do any push, the remote warehouse has no content, but when you see the number change in the file status in SourceTree, it means that the local warehouse has changed the file (that is, the remote warehouse and the local The content in the warehouse is inconsistent).
If we want to submit the local changes, let's talk about the changed files into the temporary storage, click on the submit button in the upper left corner, this is waiting to add the description information of this submission, and set whether to immediately push to the remote warehouse . After setting, we can click the submit button in the lower right corner.

 

submit

  • Pull

Pulling is to pull the changes in the remote warehouse to the local warehouse.

  • Push

Push and pull are the opposite, and will push the content that has been submitted to the remote warehouse.

  • Crawl

The crawl does not immediately update the update of the remote warehouse to the local warehouse, but will capture the modified contents of the remote warehouse for viewing.

  • Rollback

Roll back the submitted project to a previous version.

  • Branch

Branch can be used for multi-person development, giving each member an independent development space.
Creating a branch in SourceTree is easy, just click the 分支button in the upper menu :


After it is created, you can see it in the branch of the SourceTree interface.

Branch


After I submitted the content three times in the branch, there will be records in the remote repository of BitBucket:

Remote Warehouse Record (BitBucket)


It is also recorded in the local SourceTree:

Local Warehouse Record (SourceTree)

 

  • Merge branch

Generally, there are two ways to merge branches: merge into brance and merge from brance. As the name suggests, it is to merge into a branch and pull a branch to merge. The specific operation is tried in the menu in SourceTree (BitBucket can also merge branches).

 

Merge branches

There may be merge conflicts during the merge: at this time, just check which files have conflicts. (Multiple people modify the same place, and conflicts will occur. At this time, you only need to select and use a certain part.) After resolving the conflict, submit the merged branch to push. The merger is complete.
After completing the merge, you can see in SourceTree:

 

Merged successfully

7. How to add .gitignore file

By default, Git will submit all the files in the repository, but at some point, we hope that some files will not be submitted, such as the developer ’s personal user information or a large SDK file (such files are generally not Will change, everyone has one copy, no version control is required), etc.
Use .gitignore to ignore the text into the file can be ignored when the change is not asked to submit. We only need to add the file name that needs to be ignored to this file.
If a project does not create .gitignore, we need to create a file ourselves:
$ touch .gitingnore
$open .gitingnore
then add the file name of the project you want to ignore in the file. If you do n’t know what file names you should ignore, you can visit this website https://github.com/github/gitignore (this is the list of ignored files provided by github for everyone, including the corresponding files in most languages), choose your Just copy in the language you are using.

If you add .gitingnore it still has no effect. That may be because the file you want to ignore is already under version control. At this time, all local caches need to be emptied, and the command line input:
$ git rm -r --cached .
let the project return to the track state (committable). After one submission, the .gitingnore file will be effective.



Author: BennyLoo
link: https: //www.jianshu.com/p/15d8f9c1fdf8
Source: Jane books
are copyrighted by the author. For commercial reproduction, please contact the author for authorization, and for non-commercial reproduction, please indicate the source.

 

Published 105 original articles · Like 30 · Visits 160,000+

Guess you like

Origin blog.csdn.net/happygrilclh/article/details/105535281