Skip to main content
  1. Learn center
  2. Software Development
  3. Guides
  4. Git tutorial
  5. How to use Git
  6. How to use Git on Mac
  7. Commit a file
GuidesSoftware DevelopmentBacklog
Git

Project and code management together.

Commit a file

We are going to add a new file and have it registered under the repository we just created.

Create a file named sample.txt in that directory with the following text content.

Anyone can learn Git with this tutorial and Backlog

Double-click the “tutorial” repository in Sourcetree’s bookmarks window to prompt the repository operations window. If there are any newly added or edited files within the directory will be displayed in the bottom-left of the working tree file inspector.

Because we just added the sample.txt file into the tutorial directory, we see it listed there.

Repository screen

Right-click the “sample.txt” file and choose “Add to Index.” The file will move to the “Files staged in the index” list above.

Click Add to Index

Click the “Commit” icon on the toolbar, enter a commit message (e.g., “first commit”), and click “Commit.”

Enter commit message and click commit button

Once complete, you will find the commit in the “main” branch history. You can verify that the commit was successful by clicking “History” on the left menu.

The commit is added

Next, you’re ready to share the repository with your team.

Subscribe to our newsletter

Learn with Nulab to bring your best ideas to life