index manipulation quickref

3 messages, 3 authors, 2016-08-11 · open the first message on its own page

index manipulation quickref

From: Nguyen Thai Ngoc Duy <hidden>
Date: 2016-08-11 19:26:52

Hi,

I'm trying to collect all operations related to index from user
perspective and corresponding commands. The list may be put to git
wiki if people think it can help newbies:

update file content to index: git update-index file
add a file to index: git add file
delete a file from index: git update-index --remove --force-remove (or
remove that file in workdir and do git update-index --remove)
read a tree to index: git read-tree treeish, git reset treeish
read a file from a tree to index: git ls-tree treeish file|git
update-index --index-info --stdin
copy a file from index to workdir: git checkout-index file
refresh index: git update-index --refresh
copy entire index to workdir: git checkout-index
output a file from index to stdout: ?? (is there a command for this?)
list files in index: git ls-files
compare index and workdir file listing: git ls-files (with lots of options here)
diff between workdir and index: git diff
diff between index and a tree: git diff --cached treeish

Am I missing any operation here?
-- 

Re: index manipulation quickref

From: Santi Béjar <hidden>
Date: 2016-08-11 19:53:21

On 12/12/06, Nguyen Thai Ngoc Duy [off-list ref] wrote:
Hi,

I'm trying to collect all operations related to index from user
perspective and corresponding commands. The list may be put to git
wiki if people think it can help newbies:
Cool. But for "index-newbies" not "git-newbies" :)

We could add (if exists) the porcelain-ish equivalent as:

update file content to index:
  git update-index file
  git add file (the development version)

add a file to index:
  git update-index --add file
  git add file

delete a file from index:
  git update-index --remove [--force-remove] file
  git rm file

read a tree to index:
  git read-tree treeish
  git reset commit-ish # It changes also the HEAD

read a file from a tree to index:
  git ls-tree treeish file | git update-index --index-info --stdin
  N/A

copy a file from index to workdir:
  git checkout-index file
  git checkout file

refresh index:
  git update-index --refresh
  git status # It does more things

copy entire index to workdir:
  git checkout-index
  git checkout -f

output a file from index to stdout:
  git cat-file blob :file (or :n:file, where n=0,1,2,3 are the unmerged stage)
  ??

list files in index:
  git ls-files
  ??

compare index and workdir file listing:
  git ls-files (with lots of options here)
  git status?

diff between workdir and index:
  git diff-files
  git diff

diff between index and a tree:
  git diff-index --cached treeish
  git diff --cached treeish

Re: index manipulation quickref

From: Jakub Narebski <hidden>
Date: 2016-08-11 20:10:34

Nguyen Thai Ngoc Duy wrote:
I'm trying to collect all operations related to index from user
perspective and corresponding commands. The list may be put to git
wiki if people think it can help newbies:

update file content to index: git update-index file
Or "git add file" woth new git.
add a file to index: git add file
delete a file from index: git update-index --remove --force-remove
(or remove that file in workdir and do git update-index --remove)
Or "git rm file" (old version did remove only from index, new version
is to remove also from working directory if it matches HEAD)
read a tree to index: git read-tree treeish, git reset treeish
read a file from a tree to index: git ls-tree <tree-ish> file|git
update-index --index-info --stdin
copy a file from index to workdir: git checkout-index file
Or just "git checkout -- file"
refresh index: git update-index --refresh
copy entire index to workdir: git checkout-index
Or just "git checkout"
output a file from index to stdout: ?? (is there a command for this?)
"git cat-file -p ::<filename>"
list files in index: git ls-files
compare index and workdir file listing: 
   git ls-files (with lots of options here) 
diff between workdir and index: git diff
diff between index and a tree: git diff --cached <tree-ish>
diff between workdir and tree: git diff <tree-ish> 

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help