Clone your repository and manage files locally

このページの内容

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

  1. Set up SourceTree to work with Bitbucket Server
  2. Bitbucket Server での個人リポジトリの作成
  3. Clone your repository and manage files locally
  4. Bitbucket Server への変更のコミットとプッシュ

In this step you will clone your personal repository to your local computer. Cloning your repository locally creates a file directory on your computer that will kept in synch with your online repository. 

About cloning...

Making changes to live source files makes your website vulnerable to user errors. Since we all make mistakes, we instead clone the source files locally and make our changes on our own computer where we can first test that our changes won't break things in the process. Once we verify things are as they should be we then can push our changes to the live source files (usually a master branch). From there, others can pull in our changes to their local copy, and update files of the website.

  1. Clone your personal repository using SourceTree (or the command line)
    1. On the side navigation, click Clone, then Clone in SourceTree to create a local directory where you can store the website files. 

      This opens the Clone New dialog in SourceTree.
    2. Within SourceTree, choose the appropriate destination for your personal repository, then click Clone.
      You'll arrive at the empty directory in SourceTree, and an empty directory named website was created on your local computer.
  2. Download the source files and unzip them into the empty directory you just created.
  3. Add the files to your personal repository using SourceTree (or the command line).
    1. Select the files you added in the previous step by checking the box named Unstaged files.
       
      The files then appear in the Staged files pane.
    2. Click Commit, add a message in the comment box, and check the box Push changes immediately to origin/master.
       
    3. Go to your personal repository and verify the files were added.

次のステップ

Do it from the command line

  1. Clone your personal repository from the command line. You can also copy the command directly from your empty repository. Look under Working with your repository.
    From a terminal window, run these commands

    cd ~
    git clone http://<username>@<Bitbucket Server URL>/scm/<project key>/website.git
    Click for an explanation of these commands...
    cd ~
    Change directory to your home directory 
    git clone
    Command that copies the contents of the repository
    <username>
    Is the username you use to log in to the instance
    <Bitbucket Server URL>
    The URL for your Bitbucket Server instance
    <project key>
    The project key where your personal repository is
    website.git
    The name of your personal repository

    This creates an empty Git repository named TISwebsite

  2. Add the files to your personal repository from the command line.
    From a terminal window

    cd existing-project
    git init
    git add --all
    git commit -m "Initial Commit"
    git remote add origin http://<Bitbucket Server URL>/scm/tis/website.git
    git push -u origin master
    Click for an explanation of these commands...
    cd existing-project
    Change to the directory where you unzipped the files 
    git init
    Initialize the Git repository
    git add --all
    Adds the files to the repository
    git commit -m "Initial Commit"
    Adds a comment to the commit
    git remote add origin <url>
    git push -u origin master
    Adds the remote repository and pushes your files to the master branch

    次のステップ

最終更新日 2017 年 11 月 27 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.