Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions roles/git/files/git-switch-default
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
# git-switch-default - Switch to the remote default branch

# Get default branch name (from local cache without remote access)
default_branch=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@')

# Exit if symbolic reference is not found
if [ -z "$default_branch" ]; then
echo "Error: refs/remotes/origin/HEAD does not exist."
exit 1
fi

git switch "$default_branch"
7 changes: 7 additions & 0 deletions roles/git/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,10 @@

- name: Setup git-completion
ansible.builtin.include_tasks: setup_git_completion.yml


- name: Install custom commands script
ansible.builtin.copy:
src: git-switch-default
dest: /usr/local/bin/git-switch-default
mode: '0755'
Loading