Git : most short and efficient way to know about it
Venom Rex
2 min read
### `git status`
### `git init`
### `git config --global user.email "name@example.com"`
### `git add . (or) git add "file-name"`
### `git config --global user.name "name"`
### `git commit -m "commit message"`
### `git log`
### `git config`
---
### how to change code editor
a. install code command in PATH first in code editor here our (vscode) which also name as "code"
b. `git config --global core.editor "code --wait"`
### how to find git config file all details?
a. first go to home folder => `cd`
b. open the `.gitconfig` file => `cat .gitconfig`
### in the world of git every commit is dependent on the previous commit, except the first commit
it's dependent on the hash, parent, and info
---
### \*Git branch
## here we will learn something new like completely two different timelines (like Marvel Universe)
---
- check branch name => `git branch`
- create new branch => `git branch <branch-name>`
- switch branch => `git checkout <branch-name>` or `git switch <branch-name>`
- create a branch & move there => `git switch -c <branch-name>`
- delete branch => `git branch -d <branch-name>`
---
---
- `HEAD` generally pointing towards master & to the latest commit, you can check `git log --oneline` or `git log`
- we can change the branch using `git checkout <branch-name>` or `git switch <branch-name>` and then the pointing will be the `<branch-name>` & it will be the latest commit
**NOTE:**
=> Commit before switching to another branch (a good practice)
=> Go to the Git folder & check the `HEAD` file
---
### \*Merging Branch
- There are two types of merging:
1. Merging the branches
2. Not fast-forward merge
- in order to merge, you have to on that branch, whcich branch you want to merge, like if you want that your `navbar` branch get merge with `master` branch then you have to on the `master` branch
after that,
\*\*\*\* NOTE: I am merging a branch where two branch has work on completly differnt file
`git merge <branch-name>` => the branch example here will be `navbar`
`git merge navbar` => here for an example navbar branch merge to master branch
`git merge footer` => here for an example footer branch merge to master branch
so, finally, `navbar` branch got merged with `master` branch
\*\*\*\* NOTE: When get conflict on two branch what to do
you have to go manually to the file and check which changes you want to keep
1. brach a changes
2. brach b changes
3. both branch changes
and also have to remove those HEAD & aroow>>> & ===== sign
0
Subscribe to my newsletter
Read articles from Venom Rex directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by