Sunday, October 28, 2012

Git for Beginners

Common commands in the day-to-day usage of git.

Configure global email
git config --global ""
Configure global name
git config --global "username"
Generate SSH key
ssh-keygen -t rsa -C ""
View SSH key fingerprint
ssh-keygen -l -f ~/.ssh/
Add a remote repository
git remote add origin repo_url_here
Remove a remote repository
git remote rm origin
Push 'master' branch to remote repository
git push origin master
Rename a local branch
git branch -m old_branch_name new_branch_name
Delete remote branch
git push origin :old_branch
Exclude files but include a specific file in .gitignore
*.rar  #excludes all files ending in .rar
!myfile.rar #includes myfile.rar if present
Tagging a commit (give the first 7 chars of the commit)
git tag v1.0.0 dee70ed
git push origin --tags