1

I want to have a new git alias with which I can checkout file(s) from an older revision under new file name(s).

I have a git alias for showing log saved in my C:\Users\nguyen\.gitconfig

[user]
name = Tin Nguyen
email = [email protected]

[diff]
tool = winmerge

[difftool "winmerge"]
cmd = "'C:/Program Files (x86)/WinMerge/WinMergeU.exe'" -e "$LOCAL" "$REMOTE"

[alias]
    alog = log --all --decorate --oneline --graph

I tried to apply what I had with difftool but somehow I kept getting the syntax wrong.

Here a question was answered how to git checkout a file under a new file name: git-checkout older revision of a file under a new name

git show 4c274dd91dc:higgs/Higgs.xcodeproj/project.pbxproj > old_project.pbxproj
prompt> 

I want to be able to write:

git smartout 4c274dd91dc oldname.py as newname.py
1
  • I very much doubt any alias will be shorter or simpler than the git show command. Commented Jul 4, 2019 at 15:09

1 Answer 1

0
git config --global alias.smartout '!f() { !git show $1:$3 > $2; }; f'

then

git smartout 4c274dd91dc fullpath/to/oldname.py fullpath/to/newname.py

(As a sidenote, mind the small word "as" which I stripped from your desired format, because it was bringing a lot of trouble, for the only "benefit" of making each use a bit longer to type. phd's doubts about the alias' usefulness would be even more accurate with an additional word here.)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.