forked from hngprojects/hng_boilerplate_expressjs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit-script.sh
More file actions
executable file
·32 lines (25 loc) · 725 Bytes
/
Copy pathgit-script.sh
File metadata and controls
executable file
·32 lines (25 loc) · 725 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
#!/bin/bash
if [ -n "$1" ]; then
branch="$1"
else
branch=$(git rev-parse --abbrev-ref HEAD)
fi
# Fetch latest changes from the specified or current branch
git fetch origin "$branch"
# Show the difference between the current branch and the fetched changes
git diff HEAD..FETCH_HEAD
# Prompt the user for input
read -p "Want to merge? (Y/n) " answer
# Default answer to 'y' if no input is provided
if [[ -z "$answer" ]]; then
answer="y"
fi
# Convert the answer to lowercase to handle both 'Y' and 'y'
answer=$(echo "$answer" | tr '[:upper:]' '[:lower:]')
# Check if the answer is 'y'
if [[ "$answer" == "y" ]]; then
# Merge the changes if the answer is 'y'
git merge FETCH_HEAD
else
echo "Merge aborted."
fi