GIT COMMANDS
https://stackoverflow.com/questions/268736/git-svn-whats-the-equivalent-to-svn-switch-relocate
This handles my situation pretty well:
https://git.wiki.kernel.org/index.php/GitSvnSwitch
I cloned using the file:// protocol, and wanted to switch to the http:// protocol.
It is tempting to edit the url setting in the [svn-remote "svn"] section of .git/config, but on its own this does not work. In general you need to follow the following procedure:
1. Switch the svn-remote url setting to the new name.
2. Run git svn fetch. This needs to fetch at least one new revision from svn!
3. Change the svn-remote url setting back to the original URL.
4. Run git svn rebase -l to do a local rebase (with the changes that came in with the last fetch operation).
5. Change the svn-remote url setting back to the new URL.
6. Now, git svn rebase should work again.
Adventurous souls may want to try --rewrite-root.
https://help.github.com/articles/removing-sensitive-data-from-a-repository/
Run the following command, replacing PATH-TO-YOUR-FILE-WITH-SENSITIVE-DATA with the path to the file you want to remove, not just its filename. These arguments will:
1. Force Git to process, but not check out, the entire history of every branch and tag
2. Remove the specified file, as well as any empty commits generated as a result
3. Overwrite your existing tags
git filter-branch --force --index-filter \
'git rm --cached --ignore-unmatch PATH-TO-YOUR-FILE-WITH-SENSITIVE-DATA' \
--prune-empty --tag-name-filter cat -- --all
Rewrite 48dc599c80e20527ed902928085e7861e6b3cbe6 (266/266)
Ref 'refs/heads/master' was rewritten
#GIT COMMANDS#
git config --global user.name "Your Name"
git config --global user.email "you@domain.com"
git config --global credential.helper osxkeychain
git config --global core.editor "subl -wl1"
git config --global color.ui true
##Git Autocomplete##
curl -OL https://github.com/git/git/raw/master/contrib/completion/git-completion.bash
mv ~/git-completion.bash ~/.git-completion.bash
Edit ~/.bash_profile
if [ -f ~/.git-completion.bash ]; then
source ~/.git-completion.bash
fi
##Showing the current branch on the command prompt## Download git-prompt.sh
curl -OL https://github.com/git/git/raw/master/contrib/completion/git-prompt.sh
Edit ~/.bash_profile
if [ -f ~/.git-prompt.sh ]; then
source ~/.git-prompt.sh
PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
fi
##Initializing GIT##
git init (when in project directory)
initializes git for current directory and all files contained in it.
##Adding files to the staging directory##
git add file.html
or
git add directory
or
git add .
(add everything) adds selected file(s) to staging environment
git add --all
##Commit changes to a repository##
git commit -m "Write message here"
commits staged files to a commit version with the message in quotes.
##Viewing repository info##
git status
git log
##Checkout files from a repository##
git checkout <file>
discard chages in working file (or directory) and replaces with staging.
git checkout newBranch
switch to branch newBranch
git checkout -b branchName path/to/github/branch
make a local branch branchName from github for the branch specified in path/to/github/branch
##To download all branches for a project##
git clone --mirror https://github.com/path/to/repository.git .git
downloads the git directory for a project
git cofig --bool core.bare false
git reset --hard
download all branches of all files for a repsitory
##Branches##
git branch
view git branches
git branch -a
displays all branches – including ones not downloaded — for a project
git branch branchName commitHex
create branch branchName based on commit with commitHex
git branch -m oldBranchName newBranchName
move branch oldBranchName to newBranchName (rename branch)
git branch -d branchName
delete branch branchName
git branch -D branchName
force delete branch branchName (if it hasn't been merged).
git merge branchName
merge branchName into current branch
git clone githubURL.git
clone the project at githubURL to current directory
git diff
show changes on modified file (unstaged)
git diff --staged
show changes on modified files (staged)
git branch --merged
show branches that have been merged (at some point)
git branch --no-merge
show branches that haven't been merged