- 1 Tips
- 1.1 Configure http proxy
- 1.2 rebasing using git gui
- 1.3 Generate diff with no context
- 1.4 show modified files in the current directory only
- 1.5 time zone of the committer
- 1.6 cache username and passwords
- 1.7 number of commits
- 1.8 multiple repositories
- 1.9 Diff word by word
- 1.10 git and vimdiff
- 1.11 viewing diffs
- 1.12 merge a development branch into master
- 1.13 gitlab
- 1.14 external links
Configure http proxy
git config --global http.proxy http://login:email@example.com:port
rebasing using git gui
Q. How to do git pull --rebase using git gui?
A. The trick is to add a custom command in git gui:
Tools -> Add Name: Pull with Rebase Command: git pull --rebase origin Add globally -> check Add
The new command will appear under Tools menu.
Generate diff with no context
git diff -U0
In general, to generate a diff with <n> lines of context, use
git diff -U<n>
git diff --unified=<n>
The default is 3 lines of context.
show modified files in the current directory only
git status .
or more generally
git status /path/to/dir
works from git 1.7 onwards. Does not work with git 1.6.
time zone of the committer
git cat-file -p <commit-id>
Will show the entire commit object. It will contain two lines like this:
author Foo Bar <firstname.lastname@example.org> 1398017575 -0400 committer Foo Bar <email@example.com> 1398017575 -0400
As you can see, the timezone info follows the Unix-epoch timestamps.
Note that the timezone is something set by the user himself on the client. So it can be easily spoofed by the user if he desires to.
cache username and passwords
for HTTPS authentication
git config --global credential.helper wincred
This works. But how is it different from
git config --global credential.helper manager
number of commits
To get a commit count for a revision (HEAD, master, a commit hash):
git rev-list --count <revision>
To get the commit count across all branches:
git rev-list --count --all
Author of myrepos - Joey Hess. His contact info is at https://joeyh.name/contact/
Diff word by word
To diff word by word
git diff --color-words <pre></ul> To set up an alias for it <ul><pre> git config --global alias.wdiff "diff --color-words" <pre></ul> which will add the following lines to ~/.gitconfig <ul><pre> [alias] wdiff = diff --color-words <pre></ul> Once done, "git wdiff" will do the same thing as "git diff --color-words" === Useful links === ==== Migrate from sourceforge to github ==== The instructions to move a git repository from sourceforge to github are clearly laid out in https://help.github.com/articles/importing-a-git-repository-using-the-command-line/ . In particular, to migrate the sampleusage project from [https://sourceforge.net/projects/sampleusage/ sourceforge] to [https://github.com/KamarajuKusumanchi/sampleusage github], I did <pre> Login into github website create a new repository called sampleusage: https://github.com/KamarajuKusumanchi/sampleusage git clone --bare ssh://firstname.lastname@example.org/p/sampleusage/git sampleusage-git cd sampleusage-git git push --mirror https://github.com/KamarajuKusumanchi/sampleusage.git cd .. rm -rf sampleusage-git
To get a local copy
git clone email@example.com:KamarajuKusumanchi/sampleusage.git cd sampleusage git config user.name "KamarajuKusumanchi" git config user.email "firstname.lastname@example.org"
Sample work flow once it is all done
git add dummy_file git commit -m "dummy commit message" git push -u origin master
After making sure that everything on github is working properly, I submitted a ticket to delete the original sourceforge project.
git and vimdiff
- http://usevim.com/2012/03/21/git-and-vimdiff/ - contains tips on how to effectively use git, vimdiff and vim together.
- http://365git.tumblr.com/post/474079664/whats-the-difference-part-1 - explains how to diff between HEAD, Index and Working tree
merge a development branch into master
- pricing - https://about.gitlab.com/gitlab-com/
- explore project - https://gitlab.com/explore
- compare terminology across different platforms - https://about.gitlab.com/2016/01/27/comparing-terms-gitlab-github-bitbucket/