1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

すでにあるリモートブランチからSalesforce開発を始める

Posted at

前提条件

  • 以下の記事の設定が完了している

構築サイト見に行くのが面倒な人用の設定概要
Windows11 Pro 24H2 64bit
VSCode, ZuluJDK17, Salesforce CLI, Git …インストール・簡易設定済
salesforce組織への接続、Gitのローカル管理済

  • Bitbucketのアカウントをもっている
  • Gitに以下の設定を実施している
    image.png
  • VSCodeの拡張機能:Salesforce Package.xml Generator Extension for VS Code がインストールされている

設定手順

1.VSCodeでリモートリポジトリをローカルにクローンする

  • ローカルへ資産を落とすフォルダを作成する
    C:\Users\[自分のユーザ名]\work\firstrepo
  • Bitbucketへログインし、クローン対象のブランチ画面から「クローンの作成」
    image.png
  • HTTPSのコマンドをコピーする
    image.png
  • VSCodeで「Ctrl + Shift + `」でターミナルを開き先ほどコピーしたコマンドをペーストして、最初に作成した「クローン先のローカルディレクトリ」を追記する
tarminal
git clone https://[自分のユーザ名]@bitbucket.org/firstsample002/firstrepo.git C:\Users\[自分のユーザ名]\work\firstrepo

以下の画面が表示された場合は「Sign in with your browser」を押してブラウザでログインすればOK

image.png

2.VSCodeでローカル環境を整える

  • VScodeでクローンしたディレクトリを開く
    C:\Users\[自分のユーザ名]\work\firstrepo

以下の画面が表示された場合は「Yes, I trust the authors」を押す

image.png

  • 「Ctrl + Shift + p」で「create」と入力し「SFDX:Create Project with Manifest」を選ぶ
    image.png
  • 「Empty」を選ぶ
    image.png
  • クローンしたディレクトリと同じ名前で作成する
    image.png
  • 対象ディレクトリの上の階層を選択してOverwriteする
    image.png
    image.png
  • VSCodeを再起動する(後続のSFDX機能を使える様にするため)

3.Gitの接続を確認して開発ブランチを作成する

  • gitのブランチがどこに接続しているのか確認して適切に設定する
tarminal
git branch -a // リモートとローカルの全てのブランチ確認
* main     // 現在ローカルのmainブランチいて、それしかない
  remotes/origin/HEAD -> origin/main
  remotes/origin/develop
  remotes/origin/main

git checkout -b develop origin/develop // ローカルにdevelopブランチを作成してリモートから落としてくる
branch 'develop' set up to track 'origin/develop'.
Switched to a new branch 'develop'

git branch -vv // ローカルがどのリモートに繋がっているかの確認
* develop XXXXXXX [origin/develop] Initial commit
  main    XXXXXXX [origin/main] Initial commit

git checkout -b feature/sampledev // developブランチにいる状態で開発ブランチを作成
Switched to a new branch 'feature/sampledev'

git branch // 開発ブランチが作成されて現在そのブランチにいる事を確認
  develop
* feature/sampledev
  main
  • .gitignoreへ管理対象外のファイル/フォルダを設定する(対象はお好みで)
    image.png

Gitコマンドおさらい
・フォルダ指定でclonしたい場合の書き方
git clone <リモートリポジトリ> <ローカルディレクトリ>
・対象のブランチをリモートからローカルに落としたい場合
git checkout -b <ローカルに作成したいブランチ名> origin/<リモートブランチ名>
 →チェックアウトを強制したい場合は「f」をつける
git checkout -fb <ローカル> <リモート>
・追跡しているリモートブランチを確認する
git branch -vv

4.Salesforce組織に接続して資産を取得する

  • 「Ctrl + Shift + p」で「auth」と入力し「SFDX:Authorize an Org」を選ぶ
    image.png
  • 対象の環境に適したものを選ぶ
    image.png
  • 適当に名前を付けて「Enter」を押すとSalesforceログイン画面が表示されるので、IDとPassでログインする
    image.png
  • 「Ctrl + Shift + p」で「choose」と入力し「SFDX Package.xml Generator:Choose Metadata Compornents」を選ぶ
    image.png
  • 適当に落としたい資産を選択して「UPDATE PACKAGE.XML」を押下
    image.png
  • package.xmlファイル上で右クリック → SFDX:Retrieve Source in Manifest from Org
    image.png

5.一度リモート組織に資産をUPする

チームで開発をしている場合は一度上げておくと他の人が状況を把握しやすい

  • 「Ctrl + Shift + G」を押してSource Controlを開く
    image.png
  • Changesの右にある「+」を押して「Staged Changes」側に資産がある様にする
     →この場合一部の変更のみリモートへUPしたい場合は各資産の「+」を押して追加する
    image.png
    image.png
  • 適当にコミットメッセージを記入しCommit & Pushをする
    image.png

この警告画面が出たら「OK」を押す
今後出てほしくない場合は「OK, Don't Ask Again」を押す

image.png

  • 参考にしたコミットメッセージ

  • Bitbucketにログインして実際にブランチが作成しているか確認する
    image.png
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?