Cloning a reference Git repository
In this procedure, you learn how to push code from the IBM repository to your repository.
Procedure
-
Create a Git repository on https://github.com/ or https://github.ibm.com/.
- Ensure that Initialize this repository with a README is not selected since you need to import assets from the reference repository.
- Copy the SSH URL of your new repository. For example, if the owner of the repository is WCI and the name of your repository is custom-buc-sample on GitHub, the SSH URL is:
git@github.com:WCI/custom-buc-sample.git - Open a Git command-line interface (CLI) such as Git Bash and clone the reference
repository.
git clone git@github.com:IBM/oms-buc-customization.git - Rename the currently checked out project folder
(oms-buc-customization) to your custom repository name
(<your_custom_repo_name>). For example,
custom-buc-sample. - Change to the directory.
cd <your_custom_repo_name> - Find and replace references of the old repository name
oms-buc-customization with your custom repository name. Files include but not limited to:
- package.json file
- angular.json file
- README
- All *routing.module.ts files
- Change the title in README.md and index.html
from OmsBucCustomization to a new value. For example, CustomBucSample.
- Update the /src/app/app.module.ts and
src/app/features/homehome.module.ts files.
The files contain methods and class references that start with
OmsBucCustomizationandomsBucCustomization.Replace these references with a new name. For example, CustomBucSample and customBucSample.
- Rename the folder that is used for i18n files
/src/assets/oms-buc-customization to use your repository
name. For example, /src/assets/custom-buc-sample.
- Go back to the CLI and ensure that you are in your renamed project folder (custom-buc-sample).
- Set yarn as the package manager for this Angular CLI-based
project.
ng config -g cli.packageManager yarn - Install all dependencies by using Yarn.
yarn installNote:- To clear yarn cache, use:
yarn cache clean - To ignore cache and add any dependency, use:
yarn add <any dependency name> --force
- To clear yarn cache, use:
- Run the following commands based on whether your repository has existing content.
- If your target repository (git@github.com:IBM/custom-buc-sample) is
new (not initialized with README):
Wheregit remote set-url origin git@github.com:<owner>/<repository_name>.git- <owner>: The owner of the repository. For example,
WCI. - <repository_name>The name of your repository. For example,
custom-buc-sample.
- <owner>: The owner of the repository. For example,
This command pushes all changes from the develop branch to your new repository. The develop branch is the default branch on the reference repository oms-buc-customization and is used for the DEV tenant in Order Hub.git push -u origin developThis history of the original reference repository git@github.com:IBM/oms-buc-customization.git is retained. If required, you can remove the history.
- If your target repository (git@github.com:IBM/custom-buc-sample) has
existing content:
- Change to a temporary parent folder:
mkdir tempandcd temp. - Clone the new repository to the folder:
git clone git@github.com:<owner>/<custom_repository>.git. For example,git@github.com:WCI/custom-buc-sample.git - Copy all the content from the
custom-buc-samplefolder that you changed from steps 4 to 9, except the.gitandnode_modulesfolders, intotemp/custom-buc-sample. - Reconcile and merge the content as needed.
- Install all dependencies by running the following
command.
yarn install
- Change to a temporary parent folder:
You can now view all the content in the develop branch on your new repository: git@github.com:<owner>/<repository_name>.git
Setdevelopbranch as the default branch in the Settings tab for the repository. - If your target repository (git@github.com:IBM/custom-buc-sample) is
new (not initialized with README):
- Consider creating branches (and set as protected branches with rules if
needed) to align with the number of tenants that you have. You might have more than one tenant and configure each tenant as a different type. For example, if you have four tenants, you might want to set each tenant type as DEV, QA, STAGE, or PROD. It is recommended that you configure each tenant as a unique tenant type, and then associate each tenant type to a different branch in the application's repository. The following table summarizes the association:
Table 1. Association between tenant type and Git branch Tenant environment Tenant Type Application branch in Git #1 Development DEV develop #2 Quality assurance QA master #3 Preproduction STAGE release #4 Production PROD production