Just taking notes on how to setup project in GitHub. These notes are from GitCasts and GitHub Guides.
1. Setup, Initialization and Cloning
Global setup, these apply to all projects on the system:
git config --global user.name 'User Name' git config --global user.email username@gmail.com git config --global color.status auto git config --global color.branch auto git config --global core.autocrlf true
To save project in git repository:
1. First, create the project.
2. cd to the project, then do the following:
git init git add . git ls-files --cache git commit -m "Initial Commit" git status git log
To clone existing code in the git repo:
git clone git://github.com/sammydc/publictalkscheduler.git
If it's your own repo, use this instead:
git clone git@github.com:sammydc/publictalkscheduler.git
2. Normal Workflow
Create .gitignore file, this is to specify which files we don't want to add to git, like as follows:
log/*.log tmp/**/*
Editing files and commiting to repo:
git status git add [filename] git commit OR: git commit -a -m 'My Next Commit' #automatically add and commit all changed files git ls-files --stage git rm public/robots.txt #remove a file, git not to track the file anymore git status git commit -m 'robots file removed'
Now push to remote repo:
git remote add origin git@github.com:sammydc/publictalkscheduler.git git push origin master
Take note that if you get the error message:
fatal: protocol error: expected sha/ref
You need to make sure that .git/config [remote "origin"] url entry is in the form of
git@github.com:sammydc/publictalkscheduler.git
When working on another machine, to get latest changes:
git pull
0 comments:
Post a Comment