-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathpull.sh
More file actions
executable file
·56 lines (40 loc) · 1.3 KB
/
Copy pathpull.sh
File metadata and controls
executable file
·56 lines (40 loc) · 1.3 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
# Script version 1.01.
#
# "git pull" tends to generate unnecessary merge commits.
# This script uses "git fetch" and "git merge --ff-only" to do the same without
# those merge commits. If a "fast forward" is not possible, you will get an error
# and then you will have to manually merge.
#
# Copyright (c) 2017 R. Diez - Licensed under the GNU AGPLv3
set -o errexit
set -o nounset
set -o pipefail
# set -x # Trace execution of this script.
declare -r EXIT_CODE_ERROR=1
abort ()
{
echo >&2 && echo "Error in script \"$0\": $*" >&2
exit $EXIT_CODE_ERROR
}
if [ $# -ne 0 ]; then
abort "No command-line arguments are allowed."
fi
# "git fetch" may download too much. Given the default configuration:
# [remote "origin"]
# fetch = +refs/heads/*:refs/remotes/origin/*
# All remote branches will be downloaded.
# If your network connection is slow, you may want to restrict the branches you download.
# Perhaps you only need to fetch the master/main branch most of the time, like this:
# git fetch origin master
CMD="git fetch"
echo
echo "$CMD"
eval "$CMD"
# "git merge" only merges the current branch.
#
# Switch "--ff-only" prevents unnecessary merge commits that tend to clutter the Git history while providing no real value.
CMD="git merge --ff-only FETCH_HEAD"
echo
echo "$CMD"
eval "$CMD"