What is Git
- Git is a version control system.
- Git helps you keep track of code changes.
- Git is used to collaborate on code.
- Git and GitHub are different things.
Why Git?
- Over 70% of developers use Git!
- Developers can work together from anywhere in the world.
- Developers can see the full history of the project.
- Developers can revert to earlier versions of a project.
Features of Git
- When a file is changed, added or deleted, it is considered modified
- You select the modified files you want to Stage
- The Staged files are Committed, which prompts Git to store a permanent snapshot of the files
- Git allows you to see the full history of every commit.
- You can revert back to any previous commit.
- Git does not store a separate copy of every file in every commit, but keeps track of changes made in each commit!
What is GitHub
- Git is not the same as GitHub
- GitHub makes tools that use Git.
- GitHub is the largest host of source code in the world, and has been owned by Microsoft since 2018.
Configuring git for the first time
$ git config --global user.name “”
$ git config --global user.email “”
General Git Features
1. Initializing Git
$ git init
Git now knows that it should watch the folder you initiated it
on. Git creates a hidden folder to keep track of changes..
2. Staging files/Adding files to Git repo
Staged files are files that are ready to be committed to the
repository you are working on.
When you first add files to an empty repository, they are all
untracked. To get Git to track them, you need to stage them, or add
them to the staging environment.
$ git add
Staging all files in a folder
$ git add --all
or
$ git add -A
Making a Commit
Adding commits keep track of our progress and changes as we
work. Git considers each commit change point or “save point”. It is a
point in the project you can go back to if you find a bug, or want to
make a change.
When we commit, we should always include a message.
$ git commit -m “”
Git Commit without Stage
Sometimes, when you make small changes, using the staging
environment seems like a waste of time. It is possible to commit
changes directly, skipping the staging environment.
$ git commit -a -m “”
Status of files and log
$ git status
Log of a file
Log is used to view the history of commits for a repo.
$ git log
$ git log --oneline );
Git Help
If you are having trouble remembering commands or options for commands, you can use Git help.
See all the available options for the specific command –
$ git -help
See all possible commands
$ git help --all
If you find yourself stuck in the list view, SHIFT + G to jump the end of the list, then q to exit the view.
