| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Explaining Git and GitHub. Forked from Jaime Kosoy. The following commands below are to be run in the Terminal.App for Mac OSX or Linux. For a good overview on how to use the Terminal see this tutorial. There is also a [desktop application](desktop application) for GitHub if you'd prefer to not use the Terminal.App.
The following snippet is designed to explain Vincent Driessen's git branching model, at least as well as I understand it. Special thanks to Stephen Koch for being the true master here.
Milestones of milestones of milestones. In other words:
Open up a text editor.
Type "Hello World".
Save this file.
Change the contents of that file again. Add in your own text. Save it again.
Git saves milestones of milestones.
git commit -am "By typing this command I am saving a collection of saved files."
This is great because now we can roll back to old versions of files without having to retype. Aka "source control".
However, wouldn't it be great if we could further save milestones in the cloud?
Github is two things:
All you need to do to push to Github:
git push origin master
Now one could "clone" that repository on another computer and not just get the latest code but the complete revision history on another computer.
Assuming your project is in a folder named "Project" on your Desktop.
cd ~/Desktop/Project git init git checkout -b develop touch README.md
Open the README.md file you just created in your text editor. Describe your project. I've provided a basic template below for what it's worth. Save it.
Go to Github (or Bitbucket or whereever you want to save your code in the cloud). Create a new project.
Determine your SSH clone url. On Github it's probably something like git@github.com:USERNAME/PROJECT.git. Should be on the project's page somewhere.
Add your remote.
git remote add origin {{the link you just copied}}
Breaking that down
Determine your SSH clone url. On Github it's probably something like git@github.com:USERNAME/PROJECT.git. Should be on the project's page somewhere.
cd ~/Desktop
git clone {{the link you just copied}} Project
This creates a directory named "Project", clones the repository there and adds a remote named "origin" back to the source.
cd Project git checkout develop
If that last command fails
git checkout -b develop
You now have a git repository, likely with two branches: master and develop. Now bake these laws into your mind and process:
####You will never commit to master directly. ####You will never commit to develop directly.
Instead, you will create feature branches on your machine that exist for the purpose of solving singular issues. You will always base your features off the develop branch.
git checkout develop git checkout -b my-feature-branch
This last command creates a new branch named "my-feature-branch" based off of develop. You can name that branch whatever you like. You should not have to push it to Github unless you intend to work on multiple machines on that feature.
Make changes.
git add . git commit -am "I have made some changes."
This adds any new files to be tracked and makes a commit. Now let's add them to develop.
git checkout develop git merge --no-ff my-feature-branch git push origin develop
Finished with your project?
Create a feature branch as normal.
Update the version history in the README.md file
Update this to develop as normal.
git checkout master git merge --no-ff develop git push origin master git tag v1.0.0 git push origin v1.0.0
Replace 1.0.0 in the snippet here with your appropriate versions. Now you have a tag saved.
| Back | FazBrowse Home | New Git URL |