quick way to checkout (revert workspace changes) for most but not all files?
tl;dr: what will happen if I stage a file and then run git checkout .?
Here's the situation. I have an existing directory that I want to "merge"
with the contents of a git repo (and integrate it with the repo).
I will do this by copying over the .git directory, this moves the repo but
not the files, so i can do a sane manual "merge".
The git status will show a large number of "deleted" files. I want to git
checkout these deleted files in a quick way but I also want to exclude a
few of the "modified" files to keep their current filesystem contents.
So... I can run git checkout on all the ones I want to copy over, but is
there a quicker way?
Maybe...
stage (git add) the modified files I wanna keep, then run git checkout .
use the original place that I cloned to (where i copied the .git/ dir out
of and use the file explorer to copy over the files to replace (still
requires picking them out though)
So i guess the question boils down to "does git checkout affect staged
files"?
The rest of the question is just a hugely extraneous background
situational explanation.
So I'm on a windows machine and I want to integrate my Sublime Text 3 User
package git repo which was set up from OS X.
So I go checkout my sublime-text-3-user-package repo from github:
(MSYS bash shell)
cd ~
git clone https://github.com/my-st3-user-package
cp -r my-st3-user-package/.git ~/AppData/Roaming/Sublime\ Text\
3/Packages/User
Now in my User dir I can see all the missing files and I gotta reconcile
them.
I do so for Preferences.sublime-settings, and it looks like this now.
$ git status
# On branch master
# Changes not staged for commit:
# (use "git add/rm <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# deleted: .gitignore
# deleted: Default (OSX).sublime-keymap
# deleted: GitGutter.sublime-settings
# deleted: Gitconfig.JSON-tmLanguage
# deleted: Gitconfig.tmLanguage
# modified: Package Control.sublime-settings
# deleted: README.md
# deleted: Shell-Unix-Generic.sublime-settings
# deleted: SublimeLinter.sublime-settings
# deleted: Tomorrow-Night-Eighties.tmTheme
# deleted: movemultiplelines.py
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# Package Control.ca-bundle
# Package Control.ca-list
# Package Control.cache/
# Package Control.last-run
no changes added to commit (use "git add" and/or "git commit -a")
I want to bring back all of these files except for Package
Control.sublime-settings.
No comments:
Post a Comment