Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
marlin-anet-a8
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jonas Leder
marlin-anet-a8
Commits
340f97d6
Commit
340f97d6
authored
8 years ago
by
Scott Lahteine
Browse files
Options
Downloads
Patches
Plain Diff
Add ghtp script to set remotes to HTTP or SSL
parent
4fa05913
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
buildroot/share/git/ghtp
+33
-0
33 additions, 0 deletions
buildroot/share/git/ghtp
with
33 additions
and
0 deletions
buildroot/share/git/ghtp
0 → 100755
+
33
−
0
View file @
340f97d6
#!/usr/bin/env bash
#
# ghtp (GitHub Transport Protocol)
#
# Set all remotes in the current repo to HTTPS or SSH connection.
# Useful when switching environments, using public wifi, etc.
#
GH_SSH
=
"git@github
\.
com:"
GH_HTTPS
=
"https:
\/\/
github
\.
com
\/
"
case
"
$1
"
in
-[Hh]
)
TYPE
=
HTTPS
;
MATCH
=
"git@"
;
FORMULA
=
"
$GH_SSH
/
$GH_HTTPS
"
;;
-[Ss]
)
TYPE
=
SSH
;
MATCH
=
"https:"
;
FORMULA
=
"
$GH_HTTPS
/
$GH_SSH
"
;;
*
)
echo
"Usage:
`
basename
$0
`
-h | -s"
1>&2
echo
-e
"
\e
[0;92m-h
\e
[0m to switch to HTTPS"
1>&2
echo
-e
"
\e
[0;92m-s
\e
[0m to switch to SSH"
1>&2
exit
1
;;
esac
REMOTES
=
$(
git remote
-v
| egrep
"
\t
$MATCH
"
| gawk
'{print $1 " " $2}'
|
sort
-u
|
sed
"s/
$FORMULA
/"
)
if
[[
-z
$REMOTES
]]
;
then
echo
"Nothing to do."
;
exit
fi
echo
"
$REMOTES
"
| xargs
-n2
git remote set-url
echo
-n
"Remotes set to
$TYPE
: "
echo
"
$REMOTES
"
| gawk
'{printf "%s ", $1}'
echo
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment