-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd-commit.notes
More file actions
50 lines (39 loc) · 1.43 KB
/
Copy pathadd-commit.notes
File metadata and controls
50 lines (39 loc) · 1.43 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
* // ---------- ADD ---------- // *
# Adds every file in the current directory to the staging index (will then be tracked)
git add .
# Adds all files in current directory to staging index, handlind all deletions etc.
git add --all
OR:
git add -a
# Remove a file from the staging directory
git restore --staged <file>
* // ---------- PATCH MODE ---------- // *
# Add hunks of code to the staging directory
git add --patch
OR:
git add -p
# Do it to a particular file
git add -p <filename>
# Can also enter patch mode in these other Git commands
git stash -p
git reset -p
git checkout -p
git commit -p
* // ---------- COMMIT ---------- // *
# Then, commit everything in the index with a message:
git commit -m "Type a brief summary of the change here <50 characters"
// Make sure that the summary is in present tense
# Stages AND commit all changes to tracked files
git commit -a
OR:
git commit -all
// Note that this does not include untracked files
# Multi-line commit message
git commit -a
// A new file will open up. Type the multi-line commit message at the top. Start with main heading,
// Then double line break and type the detailed commit message with changes
* // ---------- AMEND ---------- // *
# Amend the current branch
git commit --amend -m "Creates a new commit with a new message"
* // ---------- COMMIT BEST PRACTICES ---------- // *
// see commit best practices: https://medium.com/@nawarpianist/git-commit-best-practices-dab8d722de99