Git Guide
a quick guide to Git
what is git?
Back in 2005, git was created by Linus Torvalds. It's a version control system(VCS) for tracking changes in your work. there is no specific language or framework you need to work with git. it can be used for static HTML pages, node, react, etc many developers can work together on a single project without going through any trouble. it coordinates work between developers
its a- WHO MADE WHAT CHANGES AND WHEN
keeps track of code history, basically taking snapshots of your files. you decide when to take a snapshot by simply one command. also, anyone can revert back to the old version of code anytime. it's like keeping track of all the phases of your files. you make some changes and by chance, it just messes up, you can go back to a happy version of your file. =>there are 3 areas in the git working directory ---> staging area ----> local repository
=>basic commands in git $git init - this is the first command you'll run in a new project. it creates a new git repository. you go in your folder and do git init it initialize a local git repository.
$git add filename - it adds the file to the staging area, where all the changes of that file will be tracked
$git status - It displays which changes have been made, which haven't, and which files aren't being tracked by Git
$git commit - this is the command which takes the snapshot of the file when you are ready you can commit and move the file from the staging area to the local repo.
$git push - it moves local repo to remote repo like on Github
$git pull - pull latest changes from remote repository
$git clone - makes a copy of the target repository
=>Basic workflow So you created a new project file.created .html, .css, ad .js file in the project. with git init, you can make a git repo. and with git add filename(suppose git add index.html) you add that file to a staging area where all its changes will be tracked. wrote some code in files. once done with the git commit command you can create a checkpoint for your project. make sure to write a suitable commit message. once done you can use git push which makes your local repo to remote repo like on Github.
you can also do all these things with git desktop. instead of using the command line, you can GUI which makes your work much easier.
=>other things
what is a repository? collection of all the files and all their history
diff between git and Github git is a version control system where you can keep track of all your versions of project whereas github is an online hosting platform that lets you keep and manage all your repositories and also host them.
commit message feat - new feature fix - a bug fix docs - changes in documentation style - related to styling refactor - done some refactoring test - related to testing code chore - updating build tasks, etc
