Work on local source files

When you work on a Bitbucket Cloud repository, you're going to work on files locally before pushing them to Bitbucket. As you work locally, you can add files, remove files, and commit your code. 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.

Working on files in Git

If you're using the command line for a Git repository, you'll use git commands to work on files in your local repository.  See the Git documentation for more information. Here are a few basic Git commands:
Action Git command
Add all new files. git add --all
Remove a file. git rm <filename>
Commit changes. git commit -m '<commit_message>'
Enter at any time to get an idea of the git command to use next. git status

To add and commit files to a Git repository

  1. Create your new files or edit existing files in your local project directory.
  2. 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.
    Example and results:

    $ git add --all
    $ git status
    # On branch master
    # 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
    
  3. 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.

    $ git commit -m 'Initial commit of all files to the repository.'
    [master 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

Working on files in Mercurial

If you're using the command line for a Mercurial repository, you'll use hg commands to work on files in your local repository. See the Mercurial documentation for more information. Here are a few basic Mercurial commands.
Action Mercurial command
Add new files. hg add
Remove a file. hg remove <filename>
Commit changes. hg commit -m "<commit_message>"
Enter at any time to get an idea of the hg command to use next. hg status

To add and commit files to a Mercurial repository

  1. Create your new files or edit existing files in your local project directory.
  2. If you have new files, enter hg add at the command line prompt in your local project directory to add the files to the repository. Enter hg status to see the changes to be committed.
    Example and results:

    $ hg add
    adding bat.gif
    adding techw_story1.htm
    $ hg status
  3. Enter hg 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:

    $ hg commit -m 'Initial commit of all files to the repository.'
    

RELATED TOPICS

Clone a repository
Pushing Updates to a Bitbucket Repository
http://mercurial.selenic.com/wiki/GitConcepts — Overview of Git for Mercurial users, including a comparison of Mercurial and Git commands.

Was this helpful?

Thanks for your feedback!

Why was this unhelpful?

Have a question about this article?

See questions about this article

Powered by Confluence and Scroll Viewport