What is Git?

Git is a Version Control System Software. A version control keeps track of every change in your code and it allows you to go back in time when something goes wrong.

Why Use Git?

Git File Status

1. Untracked
2. Tracked
3. Commited
4. Ignored

Common Git Commands Cycle

Command Description
git add <file_name> Add a file to the staging area
git add . Add all files to the staging area
git commit -m "Commit message" Commit the staged files
git push origin <branch_name> Push the committed changes to a remote repository

Git Branch

A branch is a separate line of development, just like a multiverse. It allows you to work on a feature without affecting the main codebase. You can create a new branch with the following command:

git branch <branch_name>

to show all branches and the current branch:

git branch

to switch to a branch:

git checkout <branch_name>

Git Merge

Merging is the process of combining changes from different branches. To merge a branch into your current branch you can do:

git merge <branch_name>

Git Conflict

A conflict is a situation where two branches have made changes to the same line in a file. If that happen, git didn't know which change to keep, so it will ask you to resolve the conflict manually. You can resolve the conflict by editing the file and removing the conflict markers <<<<<<<, =======, >>>>>>>.

example of a conflict:

<<<<<<< HEAD
This is the change in the current branch
=======
This is the change in the branch you are merging
>>>>>>> branch_name

Revision #3
Created 23 November 2024 05:59:06 by CH
Updated 24 November 2024 04:07:47 by CH