-
Notifications
You must be signed in to change notification settings - Fork 0
/
notes.txt
52 lines (40 loc) · 1.59 KB
/
notes.txt
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
Init
git init is use to create a repository
Status
git status tell us the state of our working directory
Add
git add tells git to track specific files or folders
git add . track add all files
To stage certain changes with Patch Mode, we use git add -p
Ignoring Things
.gitignore files tell git what to completely ignore
Commit
git commit is use to create a commit
git commit -a tell git to add and commit (git add . + git commit)
got commit -a -m tell git to add, commit with a message in one time
Commit Logs
git log shows us all the commits that were made
git log --oneline shows a summary of all commits
Diffs
git diff <old commmit> <new commit> gives the difference between two commits
Commits
We can commit selected changes by using git commit -p
Branches
git branches are like differen universes we can experiment in
git branch shows all our branches
To create a new branch, use git branch <name>
Checkout
git checkout <branch name> switches to that branch
Branches aren't automatically updated
git checkout shifts the HEAD pointer around
We can visit an older commit using checkout <commit>
Merging
To merge changes from one branch into another, use git merge <branch name>
Conflicts ocurr if we make changes that git can't automatically combine
To fix a conflict, edit the file to be the way we want, then save and commit
Undoing things
To replace a single file with older version, use git checkout <commit> <file>
To undo an entire commit, git revert <commit>
Reset
git reset can be used to undo commits: git reset <commit> --<mode>
In --hard mode, reset rolls back to the commit and DROPS ALL CHANGES since then