Commit b7781ee370ea4a3c665d88e20b24f1923010328e

Fix `git enslave`
* Operate on `origin` remote by default.
* Escape double quotes.
* Use a variable for remote's name.
Author: xaizek
Author date (UTC): 2026-06-22 17:15
Committer name: xaizek
Committer date (UTC): 2026-06-22 17:15
Parent(s): ad1c260b372f398c3c6039765ef4064634b880bb
Signing key: 99DC5E4DB05F6BE2
Tree: 9cdad6dc98aa4a2a9b8625cc29faf79c1639f6bf
File Lines added Lines deleted
gitconfig 5 4
File gitconfig changed (mode: 100644) (index 786c3d9..cebb31a)
29 29 pend = log origin/master..HEAD pend = log origin/master..HEAD
30 30 # to be used if upstream suddenly renamed master branch # to be used if upstream suddenly renamed master branch
31 31 enslave = !run() { \n\ enslave = !run() { \n\
32 if [ -z "$1" ]";" then \n\
32 remote=${1:-origin}";" \n\
33 if [ -z \"$remote\" ]";" then \n\
33 34 echo 'error: remote name must be provided as an argument' \n\ echo 'error: remote name must be provided as an argument' \n\
34 35 return 1 \n\ return 1 \n\
35 36 fi \n\ fi \n\
36 if [ -n "$2$3$4$5" ]\n then \n\
37 if [ -n \"$2$3$4$5\" ]\n then \n\
37 38 echo 'error: expected only one argument' \n\ echo 'error: expected only one argument' \n\
38 39 return 1 \n\ return 1 \n\
39 40 fi \n\ fi \n\
40 git config --local --add "remote.$1.fetch" "+refs/heads/main:refs/remotes/$1/master" \n\
41 git config --local --add "remote.$1.push" refs/heads/master:refs/heads/main \n\
41 git config --local --add \"remote.$remote.fetch\" \"+refs/heads/main:refs/remotes/$remote/master\" \n\
42 git config --local --add \"remote.$remote.push\" refs/heads/master:refs/heads/main \n\
42 43 git config --local branch.master.merge refs/heads/main \n\ git config --local branch.master.merge refs/heads/main \n\
43 44 } && run } && run
44 45 # to be used after cloning to get sane branch naming # to be used after cloning to get sane branch naming
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/dotfiles

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/dotfiles

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master