1-Installing Git
Please download according to your operating system from the following link.
How to Confirm Installation
git --version
git version 2.43.0.windows.1
2-Git Configuration
user.name & user.email
Git configuration settings with the git config command. One of the first things you did was set up your name and email address:
git config --global user.name "Your Name"
git config --global user.email "Your Email"
core.editor
git config --global core.editor "code --wait"
This command is a Git configuration that specifies the text editor to be used for commit messages and commits. Specifically, it sets up Visual Studio Code as the editor for editing commit messages. The command is: git config --global core.editor "code --wait". This means that when Git initiates the editing of a commit message, Visual Studio Code will be launched, and the commit process will continue once the commit message has been completed.
git config --global -e
The command git config --global -e is used to edit Git's global settings in an editor. When this command is executed, the specified editor opens, displaying the global Git configuration as text. Users can then edit this text to modify the settings. After editing is complete, saving and closing the editor applies the changes.
core.autocrlf
git config --global core.autocrlf true
The command git config --global core.autocrlf true is used to modify Git settings and enable automatic conversion of line endings. This setting is primarily employed to address differences in line endings between Windows and Unix-based systems.
Specifically, when this setting is set to true, Git automatically converts the line endings of text files. This ensures that in a Windows environment, CRLF (Carriage Return Line Feed) is handled appropriately, while in Unix-based environments, LF (Line Feed) is used.
3-Getting a Git Repository
Initializing a Repository in an Existing Directory
git init .
Initialized empty Git repository in C:/Users/hanam/Desktop/sample-folder/.git/
4-workflow
create file
echo hello > file1.txt
git status
git status
On branch main
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
file1.txt
nothing added to commit but untracked files present (use "git add" to track)
git add .
git add .
git status
git status
On branch main
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: file1.txt
git commit -m "commit message"
git commit -m "initial commit"
[main (root-commit) 0318ec2] initial commit
1 file changed, 1 insertion(+)
create mode 100644 file1.txt
git status
On branch main
nothing to commit, working tree clean
git log --oneline --all --graph
got log --oneline --all --graph
5-Removing files
create a new file
echo hello > files.txt
git add .
git commit-m "create a new file"
git ls-files
git ls-files displays a list of tracked files in the specified Git repository. This includes files not only in the working directory but also those in the staging area (index) and files included in the committed history.
remove a file2.txt
rm file2.txt
It is tracked in the staging area.
git add file2.txt
git add file2.txt
I was able to remove it from the staging area.
git rm file2.txt
git rm file2.txt
git rm file2.txt is a command in Git that removes the file file2.txt from the Git repository and simultaneously stages this deletion in the staging area (Index).
6-Rename files
mv file1.txt main.js
mv file1.txt main.js
git add file1.txt
git add main.js
git status
git mv "file1.txt" "main.js"
git mv "file1.txt" "main.js"
git status
7-Ignoring file
mkdir logs
echo hello > logs/dev.log
echo logs/ > .gitignore
mkdir bin
git add .
git rm --cached bin/
fatal: not removing 'bin/' recursively without -r
git rm --cached -r bin/
git ls-files
git commit -m "Remove the bin directory that was accidentally committed."