You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
git fetch <remote-origin-name>
git checkout demo
Branch demo set up to track remote branch demo from origin.
Switched to a new branch 'demo'
(1a)
git fetch upstream
git checkout bug-fix-release-13-12-2016
Branch bug-fix-release-13-12-2016 set up to track remote branch bug-fix-release-13-12-2016 from upstream.
Switched to a new branch 'bug-fix-release-13-12-2016'
If you use this functionality frequently, you might find a git alias useful. To do that, put in your ~/.gitconfig:
[alias]
# Follow evolution of certain lines in a file
# arg1=file, arg2=first line, arg3=last line or blank for just the first line
follow = "!sh -c 'git log --topo-order -u -L $2,${3:-$2}:"$1"'" -
And now you can just do:
git follow git-web--browse.sh 155
To view the the list of commits that occurred in the file
using gitk is the easiest
# preferred way
# because it's a plumbing command;
# meant to be programmatic:
gitk /path/to/file/filename.extension
index.html
javascript/application.js
javascript/ie6.js
# another way
# less preferred for scripts
# because it's a porcelain command;
# meant to be user-facing
$ git show --pretty="" --name-only bd61ad98
index.html
javascript/application.js
javascript/ie6.js
The --no-commit-id suppresses the commit ID output.
The --pretty argument specifies an empty format string to avoid the cruft at the beginning.
The --name-only argument shows only the file names that were affected.
Use --name-status instead, if you want to see what happened to each file (Deleted, Modified, Added)
If you want to get list of all files in a commit, you can use
git ls-tree --name-only -r <commit-ish>
To view the change history of a method/function
git log -L :myfunction:path/to/myfile.c
use the combination of --stat and --oneline with the show command:
git show --stat --oneline HEAD
git show --stat --oneline b24f5fb
git show --stat --oneline HEAD^^..HEAD
# if you do not like/want the addition/removal stats
# then, you can replace --stat with --name-only
git show --name-only --oneline HEAD
git show --name-only --oneline b24f5fb
git show --name-only --oneline HEAD^^..HEAD