-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathgit_cmd
More file actions
61 lines (50 loc) · 1.52 KB
/
git_cmd
File metadata and controls
61 lines (50 loc) · 1.52 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
57
58
59
60
61
1)Configuring Git
git config --global user.name "My Name"
git config --global user.email someone@email.com
git config – list
2)Clone & Status
Clone - Cloning a repository on our local machine
git clone <- some link ->
status - displays the state of the code
git status
3)Add & Commit
add - adds new or changed files in your working directory to the Git staging area.
git add <- file name ->
commit - it is the record of change
git commit -m "some message"
4)Push Command
push - upload local repo content to remote repo
git push origin main
Init Command
init - used to create a new git repo
git init
git remote add origin <- link ->
git remote -v (to verifv remote)
git branch (to check branch)
git branch -M main (to rename branch)
git push origin main
Branch Commands
git branch (to check branch)
git branch -M main (to rename branch)
git checkout <• branch name ->
(to navigate)
git checkout -b <- new branch name -> (to create new branch)
git branch -d <- branch name -> (to delete branch)
Merging Code
Way 1
git diff <- branch name-> (to compare commits, branches, files & more)
git merge <• branch name-> (to merge 2 branches)
Way 2
Create a PR
Pull Command
git pull origin main
used to fetch and download content from a remote repo and immediately update the local repo to match that content.
Undoing Changes
Case 1: staged changes
git reset <- file name ->
git reset
Case 2: commited changes (for one commit)
git reset HEAD~1
Case 3 : commited changes (for many commits)
git reset < commit hash ->
git reset - hard <- commit hash ->