Skip to content

Instantly share code, notes, and snippets.

@BennettSmith
Created March 18, 2011 18:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BennettSmith/876607 to your computer and use it in GitHub Desktop.
Save BennettSmith/876607 to your computer and use it in GitHub Desktop.
Git Usage Notes

Generating SSH Key: - ssh-keygen -t rsa -C "account@host.com" - (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 "bsmith@idevelopsoftware.com" - 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 "bsmith@idevelopsoftware.com" Overriding settings for individual repos: - git config user.name "Some User" - git config user.email "some-email@host.com" New Repositories: - git init Pushing Existing Repository to GitHub: - cd existing_git_repo - (create a repository on github) - git remote add origin git@github.com: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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment