git log --oneline --graph-- great logging outputexport GIT_CURL_VERBOSE=1;git clone ...-- show the verbose output of the git curl
git init-- initialize a git repo in the current directory (you still need to add and commit the local files)git config -l-- view git configsgit config --global http.proxy http://proxyuser:proxypwd@proxy.server.com:8080-- set http proxy in git configgit branch -r --contains origin/my_release-- find all remote branches that contain the commits inmy_releasebranchgit diff-tree -r --root <SHA>-- see a full diff-treegit svn clone {svn_url}-- clone an SVN repo as a git repository. more info
git clone https://github.com/user/repo.git -o notorigin-- sets the remote to "notorigin"git clone -b branch_name https://github.com/user/repo.git-- clone and checkout a specific remote branchgit remote add origin https://github.com/user/repo.git-- set a new remotegit remote set-url origin https://github.com/user/repo2.git-- change the remote URL fororigingit remote update-- update the local repo with remote tracking branchesgit remote prune origin-- remove stale tracking branchesgit remote update-- update branches from remote repos. Use this if you don't see you branch usinggit branch -rgit remote -v-- verify new remote
# origin https://github.com/user/repo.git (fetch)
# origin https://github.com/user/repo.git (push)git branch -r-- view available remote branchesgit branch -vv-- view the tracking branchgit checkout --track origin/serverfix-- change the tracking branchgit diff --cached-- shows changes in indexgit rm --cached-- remove file from the index but not working dirgit clean -f -X -d-- remove all unstaged files (great for cleaning up after a build)git reset --hard HEAD-- reset your local branch to the HEAD commit (see Git Reset info)git checkout HEAD -- folder1/pom.xml-- reset a single file to the HEAD commitgit show-ref-- shows therefsfor the repo (still figuring this out)git filter-branch --prune-empty --subdirectory-filter lib master-- split out a sub dir into a repositorygit reset --soft HEAD~1-- rollback a commit
Read about the Github Flow
-
git checkout -b dnorton-dev-2 origin/release-1.0.0-- check out from a remote branch -
git push -u origin dnorton-dev-2-- push feature branch to remote repo -
git pull --rebase origin dnorton-dev-2-- pull feature branch and rebase - no extra merge commit -
git push origin :dnorton-dev-2-- delete the remote feature branch (see the git-scm page) -
Github help: syncing a fork
- Edit your ~/.gitconfig to add useful git aliases. see (Effective pull requests and other good practices for teams using github)
[alias]
hist = log --color --pretty=format:\"%C(yellow)%h%C(reset) %s%C(bold red)%d%C(reset)
%C(green)%ad%C(reset) %C(blue)[%an]%C(reset)\" --relative-date --decorate
- to debug problems with an HTTP proxy set the environmental variable
GIT_CURL_VERBOSE=1
git checkout seotweaks
git merge -s ours master
git checkout master
git merge seotweaks
See reference #7 for more info.
Remove sensitive data from a repository
- https://help.github.com/articles/adding-a-remote
- http://git-scm.com/book
- https://www.atlassian.com/git
- http://scottchacon.com/2011/08/31/github-flow.html
- http://githubtraining.s3.amazonaws.com/github-git-training-slides.pdf (great training slides)
- http://gitolite.com/gcs.html#(1) (git concepts explained)
- http://stackoverflow.com/questions/2862590/how-to-replace-master-branch-in-git-entirely-from-another-branch
- https://github.com/tiimgreen/github-cheat-sheet 👍