Skip to content

Commit 25ade3d

Browse files
committed
docs: git alias for starter code
1 parent 546f07f commit 25ade3d

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,3 +362,30 @@ What you can do is the following:
362362
```
363363
364364
6. Use `fromBranch` in your assignment config.
365+
366+
If you are doing this more often, you want to add a git alias like
367+
368+
```git
369+
[alias]
370+
new-semester = "!f() { \
371+
BRANCH=${1:-ws24}; \
372+
MSG=${2:-Initial}; \
373+
if git show-ref --verify --quiet refs/heads/$BRANCH; then \
374+
echo \"Error: Branch '$BRANCH' already exists. Please delete it first or choose another name.\"; \
375+
return 1; \
376+
fi; \
377+
CURRENT=$(git branch --show-current) && \
378+
git checkout -b $BRANCH && \
379+
COMMIT=$(git commit-tree HEAD^{tree} -m \"$MSG\") && \
380+
git reset $COMMIT && \
381+
git push origin $BRANCH && \
382+
git checkout $CURRENT && \
383+
echo \"Branch '$BRANCH' created and pushed. Returned to '$CURRENT'\"; \
384+
}; f"
385+
```
386+
387+
and use it like so
388+
389+
```sh
390+
git new-semester ws24 "Initial"
391+
```

0 commit comments

Comments
 (0)