Get started with Bitbucket Cloud
New to Bitbucket Cloud? Check out our get started guides for new users.
When you work on a Bitbucket Cloud repository, you'll need to know how to add new files and edit existing files. From there, you'll commit your changes to the repository, making it possible for you (or anyone else) to refer to that point in the repository.
You can make and commit your changes locally before pushing them to Bitbucket, or you can edit from the online editor.
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.
For a quick reference, here's a few git commands you'll use to work on files in your local repository.
Action | Git command |
---|---|
git add --all | |
Remove a file. | git rm <filename> |
git commit -m '<commit_message>' | |
Get an idea of the git command to use next. | git status |
See the Git documentation for more information.
Create your new files or edit existing files in your local project directory.
Enter git add --all at the command line prompt in your local project directory to add the files or changes to the repository. Enter git status to see the changes to be committed.
For example:
1
2
3
4
5
6
7
8
9
10
11
12
$ 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
Enter git commit -m '<commit_message>' at the command line to commit new files/changes to the local repository. For the <commit_message>, you can enter anything that describes the changes you are committing.
For example:
1
2
3
4
5
6
7
8
$ 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
If you have write access to a repository, you can edit and commit changes to the repository from the Source files. If you have read access and attempt to edit online, Bitbucket forks the repository, commits your change to the fork, and opens a pull request back to the original repository.
Here's what a file looks like in edit mode:
A. File heading – Displays the repository owner (workspace), the project where it lives, and the repository's name.
B. File options – Click 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. Edit options:
Syntax mode – Pick the appropriate file type for your file.
Indent mode – Choose from Tabs or Spaces. Bitbucket attempts to guess what you're using, but you may have to adjust.
Indent size – Update the number of spaces for an indentation. You'll only see this option when Spaces is the Indent mode.
Line wrap – Update if you want the lines in your file will wrap.
D. Preview / Commit:
View diff – Shows you the differences between your changes and the most recent version of that file on Bitbucket. After viewing the diff, click 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 clicking 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.
From the repository
Select Source in the left navigation.
Click the file you want to open.
You can search for a specific file b y entering the name in the Filter files field.
Click the Edit button to open the edit view.
Make your changes and any other updates you like to the file.
Click Commit.
Update the commit message if you'd like and press Commit again.
From a pull request
In the repository, select Pull requests in the left navigation bar or the Pull requests tab in the top navigation.
Select the pull request you want to edit.
Select the Files changed tab to display all the files that have been changed. You can also select the Commits tab to display and open specific commits, or you can select commits listed in your Activity in the Overview tab.
Approving commits may be part of your team’s workflow. To approve a commit, select the Approve button in the upper-right corner of the commit.
Was this helpful?