Git
Reference
- github-cli - command-line interface to GitHub's Issues API (v2)
See also; Vim#Git
Guides
- Git wiki
- Pro Git [1]
- Arch Linux Wiki: Git
- Git cookbook
- git - the simple guide
- http://www-cs-students.stanford.edu/~blynn/gitmagic/
- http://gitimmersion.com/
- http://try.github.com/ - interactive introduction
- https://speakerdeck.com/simonclouds/understand-git - nice one page intro slide
Articles
- Understanding Git Conceptually
- pushing and pulling
- Understanding the Git Workflow
- A successful Git branching model [2]
- A Rebase Workflow for Git
- http://mercurial.selenic.com/wiki/GitConcepts
- http://www.mail-archive.com/dri-devel@lists.sourceforge.net/msg39091.html
- http://joeyh.name/blog/entry/git_push_over_XMPP/ - an idea..
Commands
Config
git config --global user.name "Your Name Here" git config --global user.email "your_email@youremail.com" git config color.ui true git config format.pretty oneline git config --global push.default matching (will be default soon)
git config --global credential.helper 'cache --timeout=3600'
The credential helper only works when you clone an HTTPS repo URL. If you use the SSH repo URL instead, SSH keys are used for authentication.
Repo config
- git config receive.denyCurrentBranch warn - allow pushing to a non-base repo
git repo-config core.sharedRepository true - allow access by multiple users
Changing files in staging
git add . add file to staging git add * add all (except those in .gitignore) files to staging git add -p add hunks seperatly [3]
git reset --hard HEAD reset any uncommitted changes git reset --hard origin/master reset from remote master
git remote add origin <server> git remote show origin
git pull origin master get master branch from origin remote git push otherrepo <branch> stick branch on otherrepo remote
Branching and merging
git checkout <branch> switch to working on <branch> git checkout -b <branch> same as "git branch <branch> | git checkout <branch>" git checkout -- <file> checkout file from HEAD git checkout - - check out previous branch
git branch list branches with current starred git branch -a list branches (including remote) git branch <branch> create branch git branch -d <branch> delete branch
git merge <branch> merge branch, keep branch in commit log git rebase <branch> - fast-forward merge current to <branch> (?) git diff master <branch> - show difference between master and another branch
git branch --set-upstream master origin/master Branch master set up to track remote branch master from origin.
Diffs
git diff diff changes git diff --cached diff changes Link titlein staging
Conflicts
git mergetool git mergetool -t opendiff
Meld GUI is worth checking.
Tags
git tag - list repo tags git tag 1.0 <sha> - tag <sha> (branch+commit hash) with 1.0 git log - list commits with message and sha A better git log [4]
Submodules
git submodule add git@mygithost:project goes/here --branch x.y git submodule add --branch 7.x-1.x git://git.drupal.org/project/examples.git in/folder git submodule update --init - bootstrap submodules listed in .gitmodules after cloning somewhere git submodule foreach git pull origin master - update all submodules
git submodule add git@mygithost:billboard [path/optional]
git submodule init git submodule update
- Drupal Deployment with Git Submodules
- Use Git submodules to avoid storing Drupal core and contrib modules in your site's repository
- Git Submodules: Adding, Using, Removing, Updating
Patches
git diff > change.patch - create a patch git diff > [description]-[issue-number]-[comment-number].patch - create a Drupal patch git apply -v <patch> - apply patch. also; curl https://github.com/github/jobs/pull/25.patch | git am
Log
.gitignore
- man gitignore - Specifies intentionally untracked files to ignore
- https://github.com/github/gitignore - A Collection of Useful .gitignore Templates
Archive to tar
git archive [5] default output is tar git archive master | tar -x -C /somewhere/else pipe to extraction git archive --format=tar --remote=git@server:repo.git master | tar -xf -
also, Legit.
Zsh prompt symbols
Status: ✔: repository clean ●n: there are n staged files ✖n: there are n unmerged files ✚n: there are n changed but unstaged files …: there are some untracked files Branch: ↑n: ahead of remote by n commits ↓n: behind remote by n commits ↓m↑n: branches diverged, other by m commits, yours by n commits :: hash, not a branch
GUI
- http://www.kernel.org/pub/software/scm/git/docs/git-gui.html
- http://sourceforge.net/projects/qgit/ - qt
- https://live.gnome.org/giggle - viewer
- http://www.syntevo.com/smartgit/index.html - java
Handy
- https://github.com/ndbroadbent/scm_breeze - to check
Services
GitHub
- willitmerge - A command line tool to check if pull requests are mergeable.
- http://gitfm.com/ - project recommendations
- Ost.io ("open-source talks") is a forum for open-source projects and the best place for discussing project stuff with other users. It is tightly integrated with GitHub.
Gist
- https://github.com/defunkt/gist - gists from the commandline
- https://github.com/ConradIrwin/jist - active fork of above with oauth
Other
- https://bitbucket.org - free private repos
- https://gitorious.org
Repos
Git used for private repo, with Gitweb for easy overview.
For a public setup, a hosting system with access control like gitosis or gitolite is required, or for public read only, git-daemon would do.
GitLab
- GitLab is a free project and repository management application