Skip to content

Commit 97adbbd

Browse files
committed
added: New Blog Post - Basic Git Commands
1 parent 82e1aa9 commit 97adbbd

File tree

1 file changed

+107
-0
lines changed

1 file changed

+107
-0
lines changed
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
---
2+
title: Basic Git Commands
3+
author: alkaison
4+
date: 2023-02-08 16:00:00 +0530
5+
categories: [Blogging, Git & GitHub]
6+
tags: [git, github, git terminal, version control]
7+
---
8+
9+
### Git Init
10+
11+
- To setup git tracking in a project use this command and you are good to go.
12+
13+
```terminal
14+
git init
15+
```
16+
17+
- Git now knows that it should watch the folder you initiated it on. Git creates a hidden folder to keep track of changes.
18+
19+
### Staging / Adding files to Git repo
20+
21+
- Staged files are files that are ready to be committed to the repository you are working on.
22+
- When you first add files to an empty repository, they are all untracked. To get Git to track them, you need to stage them, or add them to the staging environment.
23+
24+
```terminal
25+
git add <filename with extension>
26+
```
27+
28+
#### Staging all files in folder
29+
30+
- Any of this commands can be used to stage all the modified files in the repository.
31+
32+
```terminal
33+
git add --all
34+
```
35+
36+
```terminal
37+
git add --A
38+
```
39+
40+
```terminal
41+
git add .
42+
```
43+
44+
### Git Commit
45+
46+
- Adding commits keep track of our progress and changes as we work. Git considers each commit change point or "save point".
47+
- It is a point in the project you can go back to if you find a bug, or want to make a change.
48+
- When we commit, we should always include a message. It helps other contributers and ourself to know what changes we made in past.
49+
50+
```terminal
51+
git commit -m "<Enter your message here>"
52+
```
53+
54+
### Git Commit without Stage
55+
56+
- Sometimes, when you make small changes, using the staging environment seems like a waste of time. It is possible to commit changes directly, skipping the staging environment.
57+
58+
```terminal
59+
git commit -a -m "<Enter your message here>"
60+
```
61+
62+
### Git Status
63+
64+
- To know the status of the current repository and check for the modified files, you can use this command.
65+
66+
```terminal
67+
git status
68+
```
69+
70+
#### More compact way
71+
72+
- To get the status instantly in more compact way, use this command.
73+
74+
```terminal
75+
git status --short
76+
```
77+
78+
### Git Log
79+
80+
- To check the history of the past commits and changes you can use this commands.
81+
- Log is used to view the history of commits for a repo.
82+
83+
```terminal
84+
git log
85+
```
86+
87+
> Use <kbd>q</kbd> to exit the log viewing mode. You can use <kbd>DOWN ARROW</kbd> to view more past logs.
88+
{: .prompt-tip}
89+
90+
### Git Help
91+
92+
- If you are having trouble remembering commands or options for commands, you can use Git help.
93+
94+
- See all the available options for the specific command:
95+
96+
```terminal
97+
git <command> -help
98+
```
99+
100+
- See all possible commands:
101+
102+
```terminal
103+
git help -all
104+
```
105+
106+
> If you find yourself stuck in the list view, <kbd>SHIFT + G</kbd> to jump the end of the list, then <kbd>q</kbd> to exit the view.
107+
{: .prompt-tip}

0 commit comments

Comments
 (0)