Git Notes
git config --global user.email "myemail@main.com"
git config --global user.name "my name"
When working with Git, you take snapshots of your project at different points in time. These snapshots represent the history of your project and are stored in the Git repository (directory).
Each time of commit, you take a snapshot of your project.
These snapshots represents the history of your project and includes in git directory.
Within a git directory, there are two types of files:
We can initialize a git repo by using 'git init' command.
A Good Commit Message :
A Short Description
--Empty Line--
Approximately 50 charter summary. Can be add links.
Usual Git Operations:
git status :
git log : show the previous changes
git log -p : show changes with differences
git log --stat : statics about changes
git show
git diff : show the changes (unstage)
git diff --stage: show the changes (stage)
git rm <file name> : Delete a file
git mv <Initial name> <Final name> : Rename a file
A Pointer to a particular commit. The default branch name initially created os 'master'.
Simply put, a branch in Git is like a new folder. However, unlike traditional folders, Git branches offer several benefits. Most importantly, we can automatically merge changes from a working branch into the main branch. This allows us to experiment with the project without affecting the main project files. If the experiment provides positive results, we can automatically incorporate those changes or new features into the main project.
git branch : See Available Branches
git branch <new-branch-name> : Create a new branch
git checkout <branch-name> : Select a branch
git checkout -b <new-branch-name> : Create and Select a branch
git merge <branch-name> : Merge a branch with currently selected branch
git branch -d <branch-name> : delete a branch
git log --graph --oneline
Git uses two different algorithms to perform a merge.