forked from madandevops11/repo5
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit commands
More file actions
158 lines (108 loc) · 4.16 KB
/
git commands
File metadata and controls
158 lines (108 loc) · 4.16 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
Git installation:
# sudo apt update
# sudo apt install git
# git --version
# Create a new remote repo in git hub.
# git clone <git repo url>
Setup git:
# git config --global user.name "Your Name"
# git config --global user.email "youremail@domain.com"
1. Check the branch first:
# git branch
2. Create New branch
# git branch <branchname>
3. Switch to new branch
# git checkout <branchname>
4. Check status
# git status
5. To add file:
# git add filename
6.To check working tree status:
# git status
7. to stage file/folder(adding)
# git add <file/foldername> or git add .
8.To commit staged files to local repository:
# git commit -m "commit message"
9. Staging and committing multiple files:
# git commit -a -m "commit message"
10.Push changes to remote repo
# git push origin <branchname>
username: ---> give your git hub username
password: given the token generated
===================================================
GitHub Desktop UI tool: Everything with UI actions. It works only on MAC and Windows
Download Source: https://desktop.github.com/
VS Code Editor will automatically adapt with GitHub Desktop
Please install GitHub Desktop and immediately install VSCode
VsCode Download URL: https://code.visualstudio.com/download
Documentation: https://docs.github.com/en/desktop
++++++++++++++++++++++++++++++++++++++++++++++++++++
10. Git rm command deletes file from git repository as well as users system.
# git rm <filename>
11.Git remove file from git repository but not from system
# git rm --cached <filename>
12.To force remove a stage files
# git rm -f <filename>
13.Git commit log:
# git log
14.Working with remote repository:
# Create new GIT HUB account.
# Create new remote repository.
15.Adding remote repository to local:
# git clone <remote repo url>
17. Remote repo list:
# git remote -v
18. Git fetch:
# git fetch origin
19. Git pull
# git pull origin
17.Git Pull request
# Create PR remotely
18. Git conflict demo
2. # first switch to branch main
then
# git branch c1
madan@madan-virtual-machine:~/git/myfirstrepo$ Switched to branch 'c1'
madan@madan-virtual-machine:~/git/myfirstrepo$ git commit -m "modified s1.txt"
[c1 76a2670] modified s1.txt
1 file changed, 1 insertion(+), 1 deletion(-)
madan@madan-virtual-machine:~/git/myfirstrepo$ git push origin c1
Username for 'https://github.com': madandevops11
Password for 'https://madandevops11@github.com':
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 4 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 263 bytes | 263.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
remote:
remote: Create a pull request for 'c1' on GitHub by visiting:
remote: https://github.com/madandevops11/myfirstrepo/pull/new/c1
remote:
To https://github.com/madandevops11/myfirstrepo.git
* [new branch] c1 -> c1
madan@madan-virtual-machine:~/git/myfirstrepo$ git checkout main
Switched to branch 'main'
Your branch is up to date with 'origin/main'.
madan@madan-virtual-machine:~/git/myfirstrepo$ ls
file1.txt file2.txt readme.txt s1.txt
madan@madan-virtual-machine:~/git/myfirstrepo$ vi s1.txt
madan@madan-virtual-machine:~/git/myfirstrepo$ git add .
madan@madan-virtual-machine:~/git/myfirstrepo$ git commit -m "modified s1.txt in main"
[main 2fb7dd8] modified s1.txt in main
1 file changed, 1 insertion(+), 1 deletion(-)
madan@madan-virtual-machine:~/git/myfirstrepo$ git push origin main
Username for 'https://github.com': madandevops11
Password for 'https://madandevops11@github.com':
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 4 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 270 bytes | 270.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To https://github.com/madandevops11/myfirstrepo.git
8ee3cad..2fb7dd8 main -> main
madan@madan-virtual-machine:~/git/myfirstrepo$
Now raise PR in git hub from c1 to main branch which will show conflicts.