GIT
CONFIGURATION:
- remember passwords :
- windows:
git config --global credential.helper wincred
- linux:
git config --global credential.helper cachegit config --global credential.helpercache –timeout=`
- windows:
- Posh-Git : helps powershell with git
git config --global user.name "<user name>"git config --global user.email <e-mail>git config --global core.editor vim
Status : git status
Fetch : git fetch
Settings:
git config--list: view list of all stuff
Set up remote:
- make branch track remote:
- Given a branch foo and a remote upstream:
- As of Git 1.8.0 :
git branch -u upstream/foo
- As of Git 1.8.0 :
- Or, if local branch foo is not the current branch:
git branch -u upstream/foo foo
- Given a branch foo and a remote upstream:
Help : git help <verb>
Setting up a repository
git init: make a new repositorygit clone <URL> <directory name - optional>: pull down a repository, optionally put it into a directory with name<directory name>
Running:
git add <filename>: will add a file to the next comment “staging”git status: will report repository statusgit diff: shows you what you have changed in your filesgit commit:-m <message>: puts message in directly-a: automatically stages any changed files--amend: modifies the prior commit, you can add files and notes
git rm: removes a file, requires a commit to complete-
--chached: removes from staging area but keeps in directory
- git pull : pulls down remote repository into local
--rebase: makes a mirror rather than a branch, does not cause merging when you push
- git mv
: rename or move file - git log : history of commits
-p: shows the changes between commits-<n>: shows only themost recent commits --since: since a date--stat: shows stats for each commit (num of files changed etc..)--pretty: takes a number of args to prettify output--pretty=oneline: makes every commit one line--pretty=short: makes a shortened format--pretty=full:--pretty=fuller:--pretty=format: <format>: formats output per format spec (http://www.git-scm.com/book/en/v2/ch00/pretty_format) <- could make an output to a text file to run a script and generate a nice log
git push [remote-name] [branch-name]: pushes up
Tags:
- git tag : shows tags
-a <version>: saves a version tag-m <message>: saves a message- after the fact :
git tag -a <version> <beginning of commit checksum>
git show <verion>: shows tagged datagit push <remoterepo> --tags: pushes tag locationsgit checkout -b <newBranch> <tag>: checkout a tagged commit
Branching:
git branch: shows available branches<newBranch>: makes a new branch at your current location-d <branch>: deletes a branch-v: shows shows last commit on each branch--merged: shows which branches have been merged into the working branch--no-merged: branches which you have not merged in
git checkout <branch>: switches to a new branch, if branch does not exist, it is createdgit merge <branch in>: merges branch in with the branch which you are currently on- Deleting:
- local :
git branch -d <branch> - remote :
git push origin :<remoteBranch>
- local :
Ignoring files:
- Make a file called
.gitignore- lines with
#are ignored - use glob notation
- can use “/” for paths
- EX:
*.[oa]: ignore files ending in “o” or “a”*~: ignore files ending in ~
- thoughts : binaries (o,a). temps (tmp, *~), logs
- lines with
get a remote branch:
git fetch <origin> <branch>git checkout <branch>
Remove all of some file type
git filter-branch -f --index-filter 'git rm --ignore-unmatch *.pptx
Set Atom as Git editor
git config --global core.editor "atom --wait"
go back to a prior commit (you will loose any changes)
git reset --hard <commit to go to ex:b5c3d8b>
Certificate problems
echo -n | openssl s_client -showcerts -connect <domain, ex: github.com:443> 2>/dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > ~/Documents/gitcerts.pem
git config --global http.sslCAInfo ~/Documents/gitcerts.pem