# Git
Set upstream:
+
* `git push --set-upstream remote_name local_branch`
* `git pull --set-upstream remote_name local_branch`
Delete branch:
+
* `git branch -d xxx`
* `git branch -D xxx` (force delete)
* `git push MY_REMOTE --delete XXX`
* `git push MY_REMOTE :XXX` (identical to above)
-Move branch
+Move branch:
+
* `git checkout OLD_NAME`
* `git branch -m NEW_NAME`
Active branch in a bare repository:
+
* see `repo/HEAD` (and change it if needed)
Create a new branch and switch to it:
+
* `git checkout -b BRANCH`
Merge unrelated repositories:
+
* `git pull ../other/ master --allow-unrelated-histories --no-rebase`
## Submodules
At start:
+
* `git clone XXX --recurse-submodules`
At new one:
+
* git submodule add https://github.com/... path
* `./` is allowed, `.` is not *but only on remote paths, not local paths*
* `../other-prj.git` is also allowed
Manually:
+
* git submodule init
* git submodule update (--recursive)
Or in one command:
+
* git submodule update --init (--recursive)
If problems:
+
* git submodule deinit (--all)
If head detached:
+
* `git branch -u <origin>/<branch> <branch>`
* `git checkout -b <branch> --track <origin>/<branch>`
-Subproject commit 222a2306973db10bc76ff67f16fb1f6a44832a1f
+Subproject commit 51b84c72be735fd8efcb880b1af1e9aac4ac4dc8
if [ "$1" = "" ]; then
# Host
- cd "`dirname "$0"`" || exit 42
+ cd "`dirname "$0"`"
+ if [ $? != 0 ]; then
+ echo Cannot find directory \
+ | tee mkdocs/error.txt >&2
+ exit 42
+ fi
cd ..
- rm -f mkdocs/ok
+ rm -f mkdocs/ok mkdocs/error.txt
touch mkdocs/wip
OPTS="-v $PWD:$DDIR:rw" /opt/docker/launch.sh \
--start $DDIR/mkdocs/update.sh mkdocs \
cd mkdocs/site
git add .
if [ $? != 0 ]; then
- echo Failure to add newly built html site >&2
+ echo Failure to add newly built html site \
+ | tee mkdocs/error.txt >&2
exit 20
fi
git commit -m "`date +"Auto commit %Y-%m-%d %H:%M"`"
if [ $? != 0 ]; then
- echo Failure to commit to git >&2
+ echo Failure to commit to git \
+ | tee mkdocs/error.txt >&2
exit 21
fi
git push nikiroo html
if [ $? != 0 ]; then
- echo Failure to push html branch to nikiroo >&2
+ echo Failure to push html branch to nikiroo \
+ | tee mkdocs/error.txt >&2
exit 22
fi
+ cd - >/dev/null
else
- echo Failed to update, no remote copy started: $rep >&2
+ echo Failed to update, no remote copy started: $rep \
+ | tee mkdocs/error.txt >&2
fi
rm -f mkdocs/wip
exit $rep
cp "$DDIR/mkdocs/mkdocs.yml" "$HOME/" || exit
ln -s "$DDIR" docs || exit
mkdocs build -d "$DDIR"/mkdocs/site || exit
+rm -rf "$DDIR"/mkdocs/site/mkdocs || exit
touch "$DDIR/mkdocs/ok"