Create a new repository, make several commits, and push to GitHub/Bitbucket
Creating a new git repository in SourceTree:
In SourceTree, Bring up the ‘New Repository’ window by typing ⌘+N
or clicking the Add Repository
button. There are three ways to add repositories with this window:
- Clone Repository: Makes a copy of an existing git repository. The existing repo could be either local (elsewhere on your hard drive) or remote (e.g., on GitHub/Bitbucket).
- Add Working Copy: Adds an existing local git repository to SourceTree.
- Create Repository: Creates a new, empty local git repository.
Choose Create Repository
and click the …
to the far right of ‘Destination Path’ to choose a location for your new git repository. By default, the bookmark name will be the name of the directory containing the git repository. Double click the new bookmark entry to open your new empty git repository.
A video demonstrating the full process:
Making a series of commits in SourceTree:
The simplest workflow for using git consists of three repeated steps:
- Edit content
- Add changes to git index (aka staging)
- Commit staged changes permanently to the git repository
A video demonstrating the creation of a series of commits:
Pushing a local git repository to GitHub/Bitbucket
Having your code accessible from a remote repository has several advantages, such as:
- Helping you keep projects in sync across your home and work computers
- Facilitating collaboration
- Showcasing your work
To make your git repository available remotely, you can push a local repository to a remote destination.