-
Notifications
You must be signed in to change notification settings - Fork 50
Github
Prefer pretty pictures slides? Check out Roger Dudler's Git Guide
Alternative guide: Install git, add it to the path
When to commit, init commit and readmes
To check a project out:
git clone [email protected]:Citytracking/toner.git toner
To check a branch of a project out:
git clone [email protected]:Citytracking/toner.git toner
To switch to a new branch (will also make it if it's not existing):
git checkout -b tilefarm-redeploy
To check out a locally managed git repo (that isn't on github.com):
git clone ssh://[email protected]/var/git/serverprojectname localprojectname
** WARNING: if you have changes that aren't yet committed, and you want to save them for use later:**
git stash save
then to get them back later:
git stash pop
then make sure you’re in the right branch
(if a project has been forked somehow):
git checkout -b highroad-rework remotes/origin/highroad-rework
If I want to switch to another branch (like the 'master'):
git checkout master
then to confirm:
git branch -v
should print out:
* highroad-rework 76e0e3d comment1111
master 490a0a5 Fixed broken merge in Makefile
with the * being the active branch
To list different origins (forks) of the same project
git remote -v
To add another origin:
git remote add upstream [email protected]:migurski/Dymo.git
where “upstream” is the name of the origin that I specify, the git@* is the thing copied from github’s project page
To get the changes from the other fork/branch:
git pull upstream master
To see what Git thinks changed:
git status
To commit everything:
git commit -m "meaningful message" -a
To commit just specific file (multiple okay):
git commit -m "meaningful message" file1 file2 file3
Then to really push it up to github.com (I’m in the highroad-rework branch):
git push origin highroad-rework
To get more specific with your last commit message, after the fact:
git commit --amend
To update your files compared to the server files:
git status
to make sure you’ve checked in
then
git pull origin forkname
Make a mistake (oops!) and need to revert files back to the latest commit?
Make sure you're in the right branch first!
git checkout *
Or a specific file:
git checkout path/filename.ext
Github is odd about rsa security keys:
Use the same one as on your main drive:
scp .ssh/id_rsa* brillo.stamen:.ssh/
_which means: secure copy SPLAT to OTHERPLACE _
github-cant-push-to-master
http://stackoverflow.com/questions/7548661/git-github-cant-push-to-master
fatal: remote error: You can't push to git://github.com/my_user_name/my_repo.git Use [email protected]:my_user_name/my_repo.git
Instead:
git remote set-url origin [email protected]:my_user_name/my_repo.git
Tagging versions
http://learn.github.com/p/tagging.html
Loose connection:
cd docroot/projectname/svn-git/
git svn fetch
git svn rebase
git update-server-info
###For those who prefer git over svn, there seems to be an easy solution.
-
mkdir {projectname}
# this is the directory where you will keep your git checkout cd {projectname}
-
git init
# initialize a fresh new git repository there -
git svn init --stdlayout svn+ssh://[yourusername]@sub.domain.com/var/svn/projectname
# connect it to SVN server -
git svn fetch
# fetch data from SVN and... -
git svn rebase
# apply it to the local repository
Commit as usual during the project:
git commit -m '[message]' -a
When you've made a local change, it's one step:
-
git stash save && git svn dcommit && git stash pop
# push your local changes to SVN
To get someone else's changes:
git stash save && git svn fetch && git svn rebase && git stash pop
Now the everything should be back in sync.
###Make sure you have a consistent Github personality across all machines:
git config --global user.name "First Lastname"
git config --global user.email "[email protected]"
confirm by cat ~/.gitconfig
.
Then double check and make sure your Github account settings uses the same email.