Home > Net >  What to do with `.git_old`?
What to do with `.git_old`?

Time:03-07

I maintain a small repo (about 10 files) on one of my Linux boxes. The files are all shell scripts that I use on the box, and edit (almost exclusively) on the box. I also keep it remotely on GitHub, and update GitHub when I've made changes.

In October last year, there was a minor disaster: A script (not part of the repo) I had written to automate updates to the repo deleted all of the files in my local copy. I recovered from this, and sidelined my auto-update script until I corrected the issue.

Since then, GitHub has added requirements to use a token, or an SSH key for transactions between the GitHub server, and my local box. I added the SSH key recently, and this seems to be working OK.

I mention all of this history because I've just noticed today that there is an odd hidden file in my local repo: .git_old. From the date on the folder, I guess this was created during the restoration of my local repo (a clone of GitHub IIRC).

I have just today made a change to one of the files in the repo, and my (cautious) commit procedure begins as follows:

$ git -C ~/MyRepo status --porcelain
 D .DS_Store
?? .git_old/
$ git -C ~/MyRepo add --dry-run --all
remove '.DS_Store'
add '.git_old/COMMIT_EDITMSG'
add '.git_old/FETCH_HEAD'
add '.git_old/HEAD'
add '.git_old/ORIG_HEAD'
...
$

# other commands that will follow to make the commit*ment*: 

$ git -C ~/MyRepo commit -m "$NEWURL"
$ git -C ~/MyRepo push origin master

# at which time my GitHub repo will be in sync with my local repo (?) 

My proficiency with git is quite low, but it seems that the git add ... command is telling me that the contents of .git_old will be added to the GitHub repo?? - Is that correct?

If it is: I'm not ashamed of my battle scars, but I see no purpose in copying them to GitHub either. If .git_old serves no future purpose, I'd like to remove it from the repo - and that's the question really - Can .git_old be removed without repercussions? Any other insights and advice, esp wrt the final 2 steps in my commit procedure script above are welcome.

CodePudding user response:

Can .git_old be removed without repercussions?

Yes. And add it to your .gitignore, as you can see in this project.

Some scripts like FriendlyUser/file-track-Dapp/fixgit.sh can generate such folder or file:

# For when you have a corrupted local repo, but a trusted remote.
# This script replaces all your history with that of the remote.
# If there is a `.git`, it is backed up as `.git_old`, 
# removing the last backup.
# This does not affect your working tree.
  • Related