-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit-sync
More file actions
executable file
·42 lines (32 loc) · 812 Bytes
/
git-sync
File metadata and controls
executable file
·42 lines (32 loc) · 812 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
# Pulls master from original repo, pushes last changes to the fork repo,
# rebases current work to the new master and pushes it to both remotes
# Change base branch passing it as an argument
source helpers.sh
# Get current branch
branch="$(current_branch)"
base_branch=$1
if [ -z $1 ]
then
base_branch="main"
fi
if [ "$branch" = "master" ]
then
h1 "Branch is master. Aborting"
exit
fi
if [ "$branch" = "main" ]
then
h1 "Branch is main. Aborting"
exit
fi
h1 "Syncing $branch on top of $base_branch"
h2 "(1/2) Updating $base_branch..."
exec "git checkout $base_branch"
exec "git pull $origin_remote"
#Rebase branch to main and force push it
h2 "(2/2) Rebasing current branch..."
exec "git checkout $branch"
exec "git rebase $base_branch"
exec "git push $origin_remote"
h2 "Done!"