ソース ファイルの追加、編集、およびソース ファイルへのコミット
Bitbucket Cloud リポジトリで作業する際には、新しいファイルを追加したり、既存のファイルを編集したりする方法を知っておく必要があります。これにより、リポジトリに変更をコミットして、自身 (または別の人物) がリポジトリのそのポイントを参照できるようになります。
ローカルで変更を加えてコミットしてから Bitbucket にプッシュするか、オンライン エディターで編集できます。
ローカル ソース ファイルの編集
If you don't have a local copy of the repository on your machine or local network, see Clone a repository first to get a clone of the code.
Git での追加とコミット
次の表に、ローカル リポジトリのファイルで作業する際に使用する主な git コマンドを示します。
操作 | Git コマンド |
|---|---|
| |
ファイルを削除 |
|
| |
Get an idea of the |
|
See the Git documentation for more information.
Git リポジトリにファイルを追加およびコミットする方法
ローカルのプロジェクト ディレクトリで、新しいファイルを作成するか、既存のファイルを編集します。
ローカル プロジェクト ディレクトリで、コマンド ライン プロンプトに「
git add --all」と入力して、ファイルまたは変更をリポジトリに追加します。コミットされる変更を表示するには「git status」と入力します。例:
$ git add --all $ git status # On branch main # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # new file: 1.png # new file: 2.png # new file: 3.png # new file: 4.png # new file: 5.png # modified: file.txtコマンド ラインで「
git commit -m '<commit_message>'」と入力して、新しいファイル / 変更をローカル リポジトリにコミットします。<commit_message>には、コミットする変更についての任意の説明を入力できます。例:
$ git commit -m 'Initial commit of all files to the repository' [main 2f41d64] adding images 6 files changed, 1 insertions(+), 1 deletions(-) create mode 100644 African Daisy.png create mode 100644 Dandelion.png create mode 100644 Ixia.png create mode 100644 Spiked.png create mode 100644 Sunflower.png
ファイルをオンラインで編集する
リポジトリへの書き込みアクセス権を持っている場合は、[ソース] ファイルでリポジトリを編集したり、リポジトリに変更をコミットできます。読み取りアクセス権を持っており、オンラインで編集を試みた場合、Bitbucket はリポジトリをフォークし、変更をそのフォークにコミットしてから、元のリポジトリにオープンなプル リクエストを作成します。
編集モードではファイルは次のようになります。
A. ファイル見出し – リポジトリ所有者 (ワークスペース)、所属しているプロジェクト、およびリポジトリ名を表示します。
B. File options – Select Diff for the file's diff or History for its commit history to move away from the edit view. If you've already made changes, you'll get a message that asks if you want to cancel your changes to continue.
C. 編集オプション:
言語モード – ファイルについて適切なファイル タイプを選択します。
インデント モード – [タブ] または [スペース] を選択します。Bitbucket はインデントの自動検出機能を備えていますが、ユーザーによる調整が必要な場合があります。
インデント サイズ –インデントに使用するスペースの数を指定します。このオプションは、[インデント モード] が [スペース] の場合にのみ表示されます。
行の折り返し – ファイルの行を折り返したい場合に更新しまs。
D. プレビュー / コミット:
View diff – Shows you the differences between your changes and the most recent version of that file on Bitbucket. After viewing the diff, select Edit file to go back to the edit view.
Commit – Displays the Commit changes dialog where you can enter a commit message and save by selecting Commit.
If you have repository write access, you can commit directly to the repository or choose to Create a pull request for this change.
If you don't have write access, Bitbucket automatically creates a fork and pull request that points to the original repository.
ファイルまたは差分を編集する
リポジトリから
左側のナビゲーションで [Source (ソース)] を選択します。
Select the file you want to open.
You can search for a specific file b y entering the name in the Filter files field.Select the Edit button to open the edit view.
必要に応じて、ファイルに変更やその他の更新を加えます。
Select Commit.
必要に応じてコミット メッセージを更新し、[コミット] を再度押します。
プル リクエストから
リポジトリの左側のナビゲーション バーで [Pull requests (プル リクエスト)] を選択するか、上部のナビゲーションで [Pull requests (プル リクエスト)] タブを選択します。
編集するプル リクエストを選択します。
[変更されたファイル] タブを選択すると、変更されたすべてのファイルが表示されます。また、[コミット] タブを選択して特定のコミットを表示して開くことも、[概要] タブの [アクティビティ] にリストされているコミットを選択することもできます。
コミットを承認する
コミットの承認がチームのワークフローの一部となっている場合があります。コミットを承認するには、コミットの右上隅にある [承認] ボタンを選択します。
この内容はお役に立ちましたか?