Git is called a version control system.
- tracking code changes
- tracking who made the change
- collaborations.
Working Directory; this is where you do all the changes to your project Staged: you add all the files that went through changes to something called a staging area. this is where git notes every change that has been made.
changes include
- renaming a file.
- changing a line
- fixing a typo in any part of the file
- creating a new file
- creating a new module Commited: commit the changes. This is where git saves the changes made to the project.
configurating part is required only ones on every computer,
the reason for that is the usage of the --global flag
git config --global user.name "Your Name"
git config --global user.email "your@e.mail"
to make any folder or directory git trackable, you'll have to initialize it.
git init
to check the status of your git directory
git status
to add any file to the staging area
git add <filename>
to commitg the changes
git commit
There are a few things that might happen when you execute the git commit command.
- one following text editors
- vim (mostly set to default.)
- as soon as you enter vim, you are inside something called a command mode
- to start editing the file, you'll have to go to insert or append mode by pressing
i - to go back to command made press
esc - now in command mode execute the command
:wto save the file - exectute the command
:qto exit the editor.
- nano
- start typing the commit message
- press
ctrl+oto save - it asks you to enter the file name, do not change anything and just press enter
- press
ctrl+xto exit.
- vs code
- atom
- sublime text
- vim (mostly set to default.)
to change the editor to write the commit message
git config --global core.editor "nano/atom/code..."
to check the logs of commited messages
git log
to ignore files or directories from being tracked
- create a file named
.gitignore(without any extension) - if you are using windows, so create a file
.gitigore.to create a file without extension - save every file and folders to be ignored in seperate lines inside the
.gitignorefile