for branch in `git branch -r | grep -v HEAD`;do echo -e `git show --format="%ci %cr" $branch | head -n 1` \\t$branch; done | sort -r
Я хочу добавить коды выше.
Я добавляю в ~ / .bash_profile, так как у меня нет ~ / .bashr c
alias latest="for branch in `git branch -r | grep -v HEAD`;do echo -e `git show --format="%ci %cr" $branch | head -n 1` \\t$branch; done | sort -r"
Когда я используйте его.
latest
-bash: syntax error near unexpected token `origin/add_material_design_buttons'
Ожидается:
for branch in `git branch -r | grep -v HEAD`;do echo -e `git show --format="%ci %cr" $branch | head -n 1` \\t$branch; done | sort -r
2020-03-10 14:38:39 +0000 15 hours ago origin/develop
2020-02-25 12:54:43 -0600 2 weeks ago origin/XXXX1
2020-02-19 15:37:03 -0600 3 weeks ago origin/XXXX2
Обновлено:
Я комментирую неправильный ответ и добавляю ответ,
alias latest="for branch in `git branch -r | grep -v HEAD`;do echo -e `git show --format="%ci %cr" $branch | head -n 1` \\t$branch; done | sort -r"
и source ~/.bash_profile
, а затем latest
это все равно показывает неправильно, но может напечатать ветку, когда я 'source ~ / .bash_profile'.
WM-C02WM0T3HTD8:foundation_android zgong$ latest
-bash: syntax error near unexpected token `origin/F11277-MobileFoundation_Analytics_module'
WM-C02WM0T3HTD8:foundation_android zgong$ source ~/.bash_profile
-bash: /Users/zgong/.bash_profile: line 19: syntax error near unexpected token `origin/F11277-MobileFoundation_Analytics_module'
-bash: /Users/zgong/.bash_profile: line 19: `for branch in origin/AddLoggerModule
origin/F11277-MobileFoundation_Analytics_module
origin/F12172-MobileFoundation-ProfilingService
...
origin/upgradeMissingKotlinVersion
origin/zakavila/android_build_scripts_test;do echo -e 2020-03-10 14:38:39 +0000 2 days ago \t; done | sort -r '
Когда я открываю новый терминал и набираю «последний» в другом репо, он работает.
Почему мне нужно закрыть существующий терминал iTerm и открыть новый, чтобы он работал?