Read this first, especially chapter 2: Getting Started - git basics
First, download and install the latest version of git.
Then, set your name and email address. These will be attached to your commits. Use the following commands:
git config --global user.name "Your Name Here"
git config --global user.email "[email protected]"
Then set the default push behavior.
git config --global push.default simple
Follow these instructions to install git-flow. (You may need to install Homebrew or MacPorts first).
This article provides a good introduction to git-flow.
SourceTree is a great git client, and it's free. You can download it from here or from the Mac App Store.
-
If starting a new project, create it on Springloops first.
-
Next, you'll clone the project on your local machine. This can be done in SourceTree or via the command line.
git clone [remote repository url here]
This will create a local copy of the repository in a new directory.
-
Setup the project to use git-flow.
cd [the directory created above] git flow init -d
-
Commit to the
develop
branch until you have a major change or feature to add. Then, you may want to start a feature branch usinggit flow feature start 'feature-name'
To pull and automatically merge changes, type this:
git pull origin
If you want to pull the changes and manually merge them:
git fetch origin
Using pull
rather than fetch
usually works fairly well.
Once you've made some commits, you need to push them back to the origin server (which is on Springloops). To push changes to develop, click the Push button in SourceTree, or type:
git push [remote-name] [branch-name]
For example:
git push origin develop
If someone else has pushed changes to the origin server in the meantime, your push will be rejected. You must first pull down the remote changes, then try pushing again.
To ignore certain files or folders in your local repository, you need to add them to your .gitignore file.
Here's a quick overview of branches.
To see what branch you're currently on, you can type:
git status
git checkout develop
git checkout master
git checkout feature/login
# etc
Using git-flow, it's ok to make small changes on the develop branch, but when you want to make major changes, it's best to start a new feature branch.
git flow feature start login
This will create a branch named feature/login
in your local repository based on develop
.
To share your feature branch, you'll need to push it back to the origin.
git push origin feature/login
When you're finished with the feature and ready to merge it back in to develop, type:
git flow feature finish login
This will merge feature/login
back into develop and delete the feature branch. Then, push your changes.
git pull origin develop
git push origin develop