LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 09-25-2012, 01:53 AM   #1
Weapon S
Member
 
Registered: May 2011
Location: Netherlands
Distribution: Debian, Archlinux
Posts: 262
Blog Entries: 2

Rep: Reputation: 49
n00b needs some git hacking


I've made a terrible mistake. I did:
Code:
$git init
$git add -A *.cpp
//I didn't want all the sub-directories as well...
$git rm -r *.*
//Hm, doesn't work. Do --force or --cached?
$git rm -r --force *.*
WHOOPSIE!
It seems all the objects do exist in the git directory. They're just totally unindexed. I'd like to access them. Anybody have any experience with this? Know a good resource? HALP! Please.
(The fun part is that before a commit there is no HEAD and usual revert techniques don't work.)
 
Old 09-25-2012, 02:12 AM   #2
konsolebox
Senior Member
 
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,248
Blog Entries: 8

Rep: Reputation: 235Reputation: 235Reputation: 235
When did you make the commit? Is it possible for git to have objects when it didn't make a commit yet?
 
Old 09-25-2012, 10:51 AM   #3
Weapon S
Member
 
Registered: May 2011
Location: Netherlands
Distribution: Debian, Archlinux
Posts: 262

Original Poster
Blog Entries: 2

Rep: Reputation: 49
Cool Got it!

THERE IS NO COMMIT!
References used:
http://git-scm.com/book/en/Git-Internals-Git-Objects
http://linuxconfig.org/Bash_scripting_Tutorial

Code:
find .git/objects -type f  > /media/BAD/SDevX/my/PE_gitbu/recover/index.txt
#edit file to contain only last directory (without /) and filenames
#write bash script script1
chmod +x ./script1.sh
./script1.sh edited_index.txt
The bash script:
Code:
#!/bin/bash
# Link filedescriptor 10 with stdin
exec 10<&0
# stdin replaced with a file supplied as a first argument
exec < $1
while read LINE; do
    echo `git cat-file -p ${LINE} > /media/BAD/SDevX/my/PE_gitbu/recover/try1/${LINE}.cpp`
done
# restore stdin from filedescriptor 10
# and close filedescriptor 10
exec 0<&10 10<&-
Now I have a directory full of oddly named files. The names are based on the contents only; i.e. not file location. Tree objects describe the (original) location of files. None of these objects was a tree
Well, at least I have my code back.
 
Old 09-25-2012, 11:13 AM   #4
konsolebox
Senior Member
 
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,248
Blog Entries: 8

Rep: Reputation: 235Reputation: 235Reputation: 235
Well what just confuses me is why would there be even a record if no commit was made. 'git init' just initializes the repo, and 'git add' just adds references -> would that have to include data among files since by commit it has to update itself again anyway. Why would it make a cache just in case. So what's confusing is why would you even have a data about those files. Perhaps it's just a necessary step to protect data - not really as a strict compliance to necessary procedures.
 
Old 09-25-2012, 03:33 PM   #5
Weapon S
Member
 
Registered: May 2011
Location: Netherlands
Distribution: Debian, Archlinux
Posts: 262

Original Poster
Blog Entries: 2

Rep: Reputation: 49
Wink I'm just a n00b who needs his files

I was as surprised by the fact that git can remove files I hadn't added to any tree, as I was that git actually keeps a copy of deleted files.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] git push in a git-init without --bare option? xeon123 Linux - Newbie 1 06-27-2011 03:44 AM
[SOLVED] Can't install Git repo (I don't git git ) Nemus Linux - Software 3 05-20-2011 02:09 PM
SBo-git - slackbuilds.org on git (with patches for current) ponce Slackware 47 03-12-2011 05:12 AM
inconsistency issue of git-clone ***/git/mesa/drm with the existing kernel source centguy Linux - Desktop 2 10-08-2008 10:36 PM
Hacking Exposed Wireless Hacking Chapter prompt Linux - Wireless Networking 0 05-08-2004 02:44 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:59 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration