Are You familiar with Git &GitHub?

Are You familiar with Git &GitHub?

Git is an open-source distributed version control system, and it serves as a source code repository tool, which is used to integrate our source code in the GitHub repository and collaborate with other developer's code, and it is used to track changes in our code and maintains the history of your project.

checkout here for installation-Git - Downloads (git-scm.com)

GitHub is a platform where we can store your code in GitHub repository.

They are three areas that are Working directory tree, Staging area, local repository.

gitinit: it used to initialize a git repository in your Working directory, it creates .git folder which acts as your local repository (.git is a hidden folder we ca access using " ls -a" command)

I have created a file in my current directory using Linux command 'touch names.txt'.

gitstatus: this command is used to track our location of files, modifications of files.

gitadd: It is used to add our files into the staging area from working directory.

Untracked means it is present in working directory.

git commit -m"<msg>": It is used add our files from staging area to local repository.

Once you've created your repository, you can fetch the URL to git by clicking the 'Code' button on your repository page and copying the URL provided.

Git remote add origin <URL>: It's saying you want to add a remote repository with the name origin and associate it with the specified URL.

git push -u <remote-name> <branch-name>: It is to push our files into the remote repository, -u means it establish a connection between local branch to remote branch.

Git Branches:

git branch command is to check which branch is located.

git branch <branch -name>: To create a new branch on your remote repository.

git checkout <branch-name>:to switch one branch to another branch.

To add our files to a remote repository, we need to add the URL of your repository to Git.

git log: it used to check the history what commit we've done; it shows date time.

why we create branches?

Maintaining the code for each functionality separately indeed simplifies the process. It's always a good to avoid committing all changes to one branch. Instead, opting for multiple branches can help manage the code better.

git merge <branch name>: It is used to merge one branch to another branch.

what is git stash?

Imagine if you are working in a directory if you want to switch the branch then let's say you don't want to commit the present changes and also don't go to backstage and save you work on somewhere and after you work done to get those commits.

git stash: to save the work in temporary directory. and git stash pop is to the get saved work in the temporary directory.