Use Git Commands to Manage Files

To access and manage your project’s Git repository files from your computer, use a Git client - perhaps the Git CLI.

Here are some of the most common Git commands you can run in the Git CLI to work on files in your local Git repository:

Run this command ... To:
git clone <repository-url> Clone a project's Git repository to your computer:

git clone https://john.doe%40example.com@developer.us.oraclecloud.com/developer1111-usoracle22222/s/developer1111-usoracle22222_myproject/scm/developer1111-usoracle22222_myproject.git

Note:

Git over HTTPS works if your Cloud account uses federation with Oracle Identity Cloud Service. If you are federating with other identity providers, such as Microsoft Azure Active Directory or Microsoft Active Directory, Git over HTTPS won't work. We recommend using Git over SSH instead, when you use federation with identity providers other than Oracle Identity Cloud Service.

git add <filename>

Add a file that you've added to the repository's directory to the repository's index:

git add readme.txt

Add all new files to the index:

git add --all

To add a directory and all its contents to the index, navigate to the directory and use this command:

git add .

git rm <filename>

Remove a file from the repository:

git rm readme.txt

git status

Check the status of added and edited files:

git status

git branch

Create a branch:

git branch new_branch

List all branches in the repository:

git branch

Delete a local branch:

git branch -d local_branch

If the branch contains commits that haven't been merged into any other local branches or pushed to a remote repository, Git may not perform the deletion. This protects you from inadvertently losing commit data. To force the deletion regardless, use the -D option instead.

To delete a remote branch, you must use the git push command:

git push origin --delete remote_branch

git checkout

Checkout and switch to a branch:

git checkout new_branch

Pass the -b option in to the git checkout command to create a branch and switch to it immediately:

git checkout -b new_branch

git merge

Merge a branch with the checked out branch:

git merge new_branch

git commit Commit changes to the local Git repository:

git commit -m "Initial commit"

git pull

Incorporate changes from the project's Git repository to the local Git repository:

git pull origin main

git push

Push commits to the project's Git repository:

git push -u origin main

To display the Git help index, use the git help command. Use the git help git command to open the help index in a web browser. To display help for a particular command, use the git help <command>.