@@ -8,16 +8,16 @@ followed the easiest process.
8
8
> If you think that these can be improved in anyway, please do suggest. Pull Request are highly appreciated. Find me if you wish [ @Saif (https://www.linkedin.com/in/saif-aust-cse/ ).
9
9
10
10
## Workflow
11
-
11
+
12
12
<div style =" text-align : center ;" >
13
13
<img src="https://github.com/saifaustcse/Git-workflow-and-commands/blob/main/images/workflow.png" width="750" height="450">
14
14
<div >
15
15
16
16
## Commands
17
17
18
18
### Configuration
19
-
20
- Git config that lets you get and set configuration variables that control all aspects of how Git looks and operates.
19
+
20
+ Git config that lets you get and set configuration variables that control all aspects of how Git looks and operates.
21
21
22
22
# Display the current Git configuration.
23
23
$ git config --list
@@ -30,16 +30,18 @@ followed the easiest process.
30
30
git config --global user.name
31
31
git config --global user.email
32
32
33
-
34
33
### Manage Repository
35
34
36
- Create a Repository in git hub/git lab then Clone the Repository
37
- * [ How to create git hub repository.] ( https://docs.github.com/en/free-pro-team@latest/github/getting-started-with-github/create-a-repo )
35
+ Create a Repository in git hub/git lab then Clone the Repository
36
+
37
+ - [ How to create git hub repository.] ( https://docs.github.com/en/free-pro-team@latest/github/getting-started-with-github/create-a-repo )
38
+
38
39
39
40
# Download an existing git repository to your local computer with its entire code history.
40
41
$ git clone [ url]
41
42
42
-
43
+
44
+
43
45
### Adding files and folder (Workspace --> Staging)
44
46
45
47
# Add the specified file from the current directory to the staging.
@@ -98,7 +100,8 @@ followed the easiest process.
98
100
99
101
# merge a branch into a target branch
100
102
$ git merge [source branch] [target branch]
101
-
103
+
104
+
102
105
### Workspace synchronization from remote (Workspace <-- Repository <-- Remote)
103
106
104
107
# Retrieve the changes to the Remote Repository and merge with the local branch (fetch+merge)
@@ -133,7 +136,8 @@ followed the easiest process.
133
136
# Delete the remote branch.
134
137
$ git push origin --delete [branch-name]
135
138
$ git branch -dr [remote/branch]
136
-
139
+
140
+
137
141
### Inspection
138
142
139
143
# Display the changed files.
@@ -163,12 +167,11 @@ followed the easiest process.
163
167
# Show the latest commits of the current branch.
164
168
$ git reflog
165
169
166
- For more details:
167
-
168
- * [ The-official-Git-site] ( https://git-scm.com/book/en/v2/Git-Basics-Viewing-the-Commit-History )
169
- * [ Atlassian] ( https://www.atlassian.com/git/tutorials/git-log )
170
- * [ Thegeekstuff] ( https://www.thegeekstuff.com/2014/04/git-log/ )
170
+ For more details:
171
171
172
+ - [ The-official-Git-site] ( https://git-scm.com/book/en/v2/Git-Basics-Viewing-the-Commit-History )
173
+ - [ Atlassian] ( https://www.atlassian.com/git/tutorials/git-log )
174
+ - [ Thegeekstuff] ( https://www.thegeekstuff.com/2014/04/git-log/ )
172
175
173
176
### Discard changes from Workspace
174
177
@@ -182,11 +185,11 @@ followed the easiest process.
182
185
183
186
# If unwanted file were added to the staging area but not yet committed.
184
187
# Restore specified file from the Staging to the Workspace.
185
- # Changes will stay in workspace.
188
+ # Changes will stay in workspace.
186
189
$ git reset [file]
187
190
188
191
# Restore all files from the Staging to the Workspace.
189
- # Changes will stay in workspace.
192
+ # Changes will stay in workspace.
190
193
$ git reset
191
194
$ git reset HEAD .
192
195
@@ -212,7 +215,6 @@ followed the easiest process.
212
215
# Undo the last commit.
213
216
$ git reset --hard HEAD~1
214
217
215
-
216
218
### Revoke/Undo from Remote (Workspace <-- Staging <-- Repository <-- Remote)
217
219
218
220
# Create a new commit to undo the specified commit.
@@ -221,41 +223,42 @@ followed the easiest process.
221
223
$ git revert [commit]
222
224
$ git commit -m "message"
223
225
$ git push origin [branch]
224
-
226
+
225
227
### Removing files or folders (Workspace --> Staging --> Repository --> Remote)
226
-
228
+
227
229
# Manually delete the files or folders from Workspace
228
- # The following command will permanently remove the files or folders
230
+ # The following command will permanently remove the files or folders
229
231
$ git add .
230
232
$ git commit -m "message"
231
233
$ git push origin [branch]
232
-
234
+
235
+
233
236
### Stash
234
237
235
238
# Temporarily saves or stashes changes of working copy and and move them in later.
236
239
$ git stash
237
240
238
241
# Saving Stashes with the message
239
- $ git stash save "<Stashing Message>"
242
+ $ git stash save "<Stashing Message>"
240
243
241
244
# Check the Stored Stashes
242
- $ git stash list
243
-
245
+ $ git stash list
246
+
244
247
# Restored the changes of latest stash from stashes
245
248
# Remove the latest stash from stashes
246
249
$ git stash pop
247
250
248
251
# Restored the changes of latest stash from stashes
249
- $ git stash apply
250
-
252
+ $ git stash apply
253
+
251
254
# Restored the changes of specific stash from stashes
252
255
$ git stash apply <stash id>
253
256
254
257
# Remove the latest stash from stashes
255
258
$ git stash drop
256
259
257
260
# Remove the specific stash from stashes
258
- $ git stash drop <stash id>
261
+ $ git stash drop <stash id>
259
262
260
263
# Remove all stashes
261
264
$ git stash clear
@@ -294,29 +297,27 @@ followed the easiest process.
294
297
# Tag is nothing but a reference name of a commit
295
298
# Multiple tag name is possible for same commit
296
299
297
- ### cherry-pick
300
+ ### cherry-pick
298
301
299
302
# Select a commit to be merged into the current branch.
300
303
$ git cherry-pick [commit]
301
304
302
305
### Checkout vs Reset vs Revert
303
306
304
- * [ Atlassian] ( https://www.atlassian.com/git/tutorials/resetting-checking-out-and-reverting )
305
- * [ Medium] ( https://medium.com/@manivel45/git-merge-vs-rebase-reset-vs-revert-vs-checkout-dd5674d0e18a )
306
- * [ opensource] ( https://opensource.com/article/18/6/git-reset-revert-rebase-commands )
307
+ - [ Atlassian] ( https://www.atlassian.com/git/tutorials/resetting-checking-out-and-reverting )
308
+ - [ Medium] ( https://medium.com/@manivel45/git-merge-vs-rebase-reset-vs-revert-vs-checkout-dd5674d0e18a )
309
+ - [ opensource] ( https://opensource.com/article/18/6/git-reset-revert-rebase-commands )
307
310
308
311
### Merging vs. Rebasing
309
312
310
- * [ Atlassian] ( https://www.atlassian.com/git/tutorials/merging-vs-rebasing )
311
-
313
+ - [ Atlassian] ( https://www.atlassian.com/git/tutorials/merging-vs-rebasing )
312
314
313
315
# References
314
316
315
- I have followed many articles but among them, the following articles are really helpful. Those articles helped me a lot and also encourage me to write this article according to my understanding.
316
-
317
- * [ The-official-Git-site] ( https://git-scm.com/book/en/v2 )
318
- * [ Atlassian] ( https://confluence.atlassian.com/bitbucketserver/basic-git-commands-776639767.html )
319
- * [ Git-most-frequently-used-commands] ( https://medium.com/analytics-vidhya/git-most-frequently-used-commands-9df9f200c235 )
320
- * [ Ercankaracelik] ( https://ercankaracelik.wordpress.com/2018/12/08/basic-git-commands/ )
321
- * [ Tutorialdocs] ( https://www.tutorialdocs.com/article/git-basic-command-list.html )
317
+ I have followed many articles but among them, the following articles are really helpful. Those articles helped me a lot and also encourage me to write this article according to my understanding.
322
318
319
+ - [ The-official-Git-site] ( https://git-scm.com/book/en/v2 )
320
+ - [ Atlassian] ( https://confluence.atlassian.com/bitbucketserver/basic-git-commands-776639767.html )
321
+ - [ Git-most-frequently-used-commands] ( https://medium.com/analytics-vidhya/git-most-frequently-used-commands-9df9f200c235 )
322
+ - [ Ercankaracelik] ( https://ercankaracelik.wordpress.com/2018/12/08/basic-git-commands/ )
323
+ - [ Tutorialdocs] ( https://www.tutorialdocs.com/article/git-basic-command-list.html )
0 commit comments