Generating SSH Key: - ssh-keygen -t rsa -C "[email protected]" - (save in a file like id_rsa-github) - ssh-add ~/.ssh/id_rsa-github Configuration: - git config --global user.name "Bennett Smith" - git config --global user.email "[email protected]" - git config --global github.user idvlpsw - git config --global github.token e0e9e3498b7b2780b33eece4a46fb674 - git config --global --list - git config --global color.ui "auto" - git config --global core.autocrlf input (for mac/linux) - git config --global core.autocrlf true (for windows) - git config --global core.editor vim - git config format.pretty oneline - git config --global merge.log true
User Name and E-Mail Address: Global identity: - git config --global user.name "Bennett Smith" - git config --global user.email "[email protected]" Overriding settings for individual repos: - git config user.name "Some User" - git config user.email "[email protected]" New Repositories: - git init Pushing Existing Repository to GitHub: - cd existing_git_repo - (create a repository on github) - git remote add origin [email protected]:idvlpsw/DailyShoot.git - git push origin master Adding/Updating Files: - git add - git commit -m "comment goes here" - git commit -m "comment goes here" -a Status Information: - git log ---pretty=oneline - git status Diff: - git diff - git diff --cached - git diff HEAD Ignoring/Excluding Files: - vi .git/info/exclude - vi .gitignore Branching: - git branch - git branch new - git checkout -b alternate master - git blame hello.html
To list branches:
- git branch
- Add -a to list all branches, local and remote.
- Add -r to list all branches on the remote site.
To merge changes from another branch into current branch:
- git checkout {source-branch}
- git pull origin {source-branch}
- git checkout {target-branch}
- git pull origin {target-branch}
- git merge {source-branch}
To delete a remote branch:
- git push origin :{branch-name}
Tagging: - git tag - git tag -a {tagname} -m '{comment}' - git tag {tagname} - git tag -d {tagname} - git show {tagname} Remote Repositories: - git clone git://github.com/tswicegood/mysite-chp6.git - add --branch to clone a branch from the remote repo - git fetch - git pull - git push [--dry-run] [--tags] Submodules: To add a submodule - git submodule add git://github.com/tswicegood/hocus.git hocus - git submodule init hocus - git submodule To update existing submodules - git submodule update To remove a submodule - vi .gitmodules (remove line mentioning submodule) - vi .git/config (remove line mentioning submodule) - git rm --cached path/to/submodule