How to git (and github)
Version control is important. Git is powerful and GitHub makes it easy to get your project out on the web. My workflow is (uses hub to carry out Github work from command line too):
- Create a project directory, add .gitignore and README.md
- Initialize git
git init
- Add files
git add .
- First commit
git commit -m "To begin, begin."
- Create a new Github repository with the same name as current directory
hub create
- Push local changes to Github
git push -u origin HEAD
- Think of a problem to fix or feature to add. Create and checkout a branch to work on that problem
git checkout -b fixOrAddSomething
- Stage the files created/changed to solve the problem
git add --all
- Commit the files
git commit -m "fixed or added something"
- Switch to master
git branch master
- Merge changes from branch to master
git merge fixOrAddSomething
- Push changes to Github
git push origin master
- Take a break
- Go back to step 7 and have fun!
Other useful commands
git add file(s) // add specific files
git add -u // add all modified files
git log // check log
git branch // list all branches and active branch
git branch -d someBranch // delete a branch
git reset HEAD someFile // unstage a file