Git¶
All code should be committed to version control from inception. This is a critical part of managing development and regression, and makes it much easier to share and collaborate - now or in the future. We recommend git. Free hosting is available on github for open source projects and bitbucket for private ones.
Recommended Workflow¶
Central org repo personal fork master, develop, and feature branches
from local: git fetch upstream git checkout develop
For small to medium projects (2-50 contributors), we recommend the following workflow:
Create Organization Repo¶
On github, create an organization if you don’t have one already and initialize your empty repository (do not create any files).
Clone the repository, create develop and stable branches, and push to github by following the steps below:
$ mkdir REPONAME
$ cd $REPONAME
$ git init
$ git commit --allow-empty -m'Initial commit'
$ git remote add upstream https://github.com/ORGNAME/REPONAME.git
$ git checkout -b develop
$ git branch -d master
$ git push -u upstream develop
$ git checkout -b stable
$ git push -u upstream stable
Fork Repo¶
Create a fork of the repository under your github username by clicking the fork button
Branching¶
You may find that a more complex branching process and release strategy becomes useful as your project’s code base and contributor base grows bigger. This is particularly important if one group is working on preparing code for a release while another is adding new features. Pick one (git flow branching is recommended) and document that choice in your source.
If using the develop -> stable model, it’s important to set the default branch to develop in github settings. This is the branch pull requests will be opened against, and should be set correctly if you followed the steps above.
FAQ¶
I’ve lost a file that I didn’t commit¶
Unfortunately, git can’t help you here. Commit early and often. Local backups (such as time machine) may have a copy.
I’ve lost a commit¶
git reset --hard
and git rebase
, can cause you to lose progress if you
make a mistake. Fortunately it is almost always possible to recover commits in
git using the reflog. See Data Recovery.
I’ve committed a large file and now my repository is huge¶
Large binary files generally shouldn’t be kept in source control. Github has a 100MB per file limit. If you must store a large file in source control, consider using Large File Storage.
To remove a file from your git tree, see Removing Objects.
LFS Recovery Fork pull model GUIs Github