-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
git-force-clone #591
git-force-clone #591
Conversation
7fb1d84
to
9fe6d7d
Compare
All files for git-force-clone, a command for overwriting local repos when closing repositories.
9fe6d7d
to
e476562
Compare
LGTM |
while [[ -n "${1:-}" ]] && [[ "${1:0:1}" == "-" ]]; do | ||
case $1 in | ||
-b | --branch ) | ||
branch=${2:-} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is a shift
missing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does shift
at the end of the whole case block, which seems to work. Why do I need it in here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I understand now - it needs to shift two values. I'll update.
_check "${remote_url}" "remote_url" | ||
_check "${destination_path}" "destination_path" | ||
|
||
if [ -d "${destination_path}/.git" ]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about existing directory which is not git repo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This tool provides a solution just for existing git repos. If it's anything else, I figure it makes sense to pass it through to the standard git clone
command and let it give the standard error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nottrobin
Or you need to clarity it in the docs: for target git repo
instead of target directory
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@spacewander Yep fair enough, I'll do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay I've done that.
|
||
# Set default branch | ||
if [ -z "${branch:-}" ]; then | ||
branch=`git remote show origin | grep -oP '(?<=HEAD branch: )[^ ]+$'` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A LC_ALL=C
is required to bypass localization:
~/code/lua-resty-mooncake/test(master ✔) git remote show origin
* 远程 origin
获取地址:https://github.com/spacewander/lua-resty-mooncake
推送地址:https://github.com/spacewander/lua-resty-mooncake
HEAD 分支:master
远程分支:
master 已跟踪
为 'git pull' 配置的本地分支:
master 与远程 master 合并
为 'git push' 配置的本地引用:
master 推送至 master (最新)
~/code/lua-resty-mooncake/test(master ✔) LC_ALL=C git remote show origin
* remote origin
Fetch URL: https://github.com/spacewander/lua-resty-mooncake
Push URL: https://github.com/spacewander/lua-resty-mooncake
HEAD branch: master
Remote branch:
master tracked
Local branch configured for 'git pull':
master merges with remote master
Local ref configured for 'git push':
master pushes to master (up to date)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool I'll add this.
exit 0 | ||
;; | ||
* ) | ||
if [[ "${1:0:1}" == '-' ]]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this check duplicate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep. I'll remove.
Needs an extra `shift`, to remove the second option as well.
@spacewander I've addressed 3 of your concerns. Let me know what you think about my response to the 4th - is it okay to simply let |
This expects a target git directory. If it's not a git directory, (e.g. a simple directory) then it will pass through to `git clone` which will raise an error. Here I'm clarifying that this tool will reset local *git directories* specifically.
@spacewander documentation updated. Let me know if you have any further issues. |
Thanks! |
All files for git-force-clone, a command for overwriting local repos when closing repositories.
Provides the basic functionality of
git clone
, but if the destinationrepository already exists it will force-reset it to resemble a clone of the
remote.
Because it doesn't actually delete the directory, it is usually significantly
faster than the alternative of deleting the directory and cloning the
repository from scratch.
I've only tested it on my laptop, running Ubuntu 16.04, in bash and zsh.