Here’s some basic resources to get started pushing code to github.
Note: As well as computer source code, git is useful for tracking changes to anything that can be represented as plain text, e.g. German Law.
The simplest use of git is to create the repo locally, stored in the same folder as the source (known as the working tree) and named
To initialise a new git repo, simply run
View recent commits using
To collaborate on a project using Git, an online service such as Github is used to hold a repo and allow others to access it. To propose changes to somebody else’s repo, a fork
-> pull-request process is used.
- First fork a new personal copy of the existing repo, then clone that new fork onto your local computer.
- A new “topic” branch should be used for each pull request. Commiting directly to the
masterbranch (or any other branch that recieves commits by others) will likely complicate merging of your commits upstream – as will mixing unrelated changes into the same branch.Note that all additional commits made to a branch will automatically be added to a pull request made with that branch. This makes it really easy to add commits to a pull request – just be careful not to commit any unrelated work to a branch that’s already used in an open pull request.
- Once you have committed some changes to the new branch, and pushedthose changes to Github, use the Github website to send a pull request to the project’s owner.You can view the progress of your pull request in it’s discussion thread, where you may get feedback on your changes before they can be merged. Notifications will normally be sent by email to those active or mentioned in the thread, as well as those watching either the thread or the related repo.
Git itself can be installed from git-scm.com if your OS doesn’t already include it. The same site also hosts a copy of the documentation, as well as the Pro Git book which is a great place to start learning git. Pro Git is also available as a commercially printed book from Apress, and as a free ePub, mobi, or PDFdownload.
If you don’t fancy reading an entire book, then this Git Tutorial gets straight to the point for those already familiar with the concepts of version control. There’s minimal explanatory text, but full command examples for most operations; making it a useful resource for commands you use rarely and need to quickly relearn. Also, A Hacker’s Guide to Git is recommended as being very readable.
While it’s good to know how to use git from the command line, it’s worth getting a GUI for easier building of commits etc. (you could also integrate it with your favourite editor and diff viewer)
Github offers their own Mac and Windows GUI clients, which have the advantage of closer integration with some of github’s features, such as organisations and the “Clone in Windows/Mac” button found on each repo on github.
Btw, if you just want to share some code snippets somewhere while maintaining versioning etc., then check out gists, a feature of github.
This article was originally posted at: http://jmeosbn.github.com