-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
git-helloworld.sh
62 lines (44 loc) · 1.45 KB
/
git-helloworld.sh
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
57
58
59
60
61
62
#!/bin/bash
console_log() {
echo "\e[32m>>> [Git] $1\e[0m"
}
WORKSPACE="/tmp/devops-basic/git/demo"
console_log "Cleanup previous run data"
rm -rf $WORKSPACE
console_log "Prepare new data"
mkdir -p $WORKSPACE
console_log "Clone repository"
cd $WORKSPACE
git clone [email protected]:nholuongut/devops-basics.git
console_log "Navigate to the cloned repo"
cd devops-basic
ls -la
console_log "Switch to main branch"
git checkout main
console_log "Create new development branch, from main branch"
git checkout -b my-dev-branch
console_log "Make change - Update file"
echo "Testing README.md" >>README.md
echo "Make change - New file"
console_log "Hello-world" >hello-world.txt
console_log "Check git status"
git status
#### We should see result like this:
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git restore <file>..." to discard changes in working directory)
# modified: README.md
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
# hello-world.txt
console_log "Add all the changes"
git add .
console_log "Commit the changes"
git commit -m "dev: this is my first commit"
console_log "Push the change (dry-run)"
git push origin my-dev-branch --dry-run
console_log "Just for demo! In real world, we will not use the --dry-run option"
console_log "Check git log (last 3 commits)"
git --no-pager log -n 3
console_log "Check git status - again"
git status