GIT and GITHUB Commands
GIT and GITHUB Commands
05 May 2023
Git: It is an open source version control application for tracking and managing code. Linus Torvalds, the man behind Linux, created it. Git can be used on both Windows and Mac operating systems, so you don’t have to be running Linux to use it.
A version control system allows you to keep track of changes to your papers. This allows you to easily recover prior versions of your text if you make a mistake, and it makes cooperation with others much easier.
GitHub: GitHub is a web-based platform for hosting Git repositories. It was created in 2008 and is currently a subsidiary of Microsoft. Many features on GitHub, such as pull requests, issue tracking, and code review tools, make it simple for developers to collaborate on code.
How Git and GitHub Work Together
Git and GitHub operate in tandem to make it simple for developers to collaborate on code. After creating a Git repository, a developer can submit their code to GitHub to make it available to others.
Other developers can then clone the repository and make modifications to the code on their local PC. They can then push their changes to GitHub, where the original developer can review them and, if satisfied, merge them into the main repository.
GitHub also has capabilities like pull requests and issue tracking that allow developers to easily collaborate on code and debate changes. Developers can use pull requests to request that their modifications be merged into the main repository, whereas issue tracking allows them to discuss problems with the code and provide remedies.
There are three step to push our code from local repository to remote repository
Terms Related to Git
- Repository: A repository contains your project folders that are set up for version control.
- Fork: Copy of a repository.
- Pull Request: A pull request is the way you request that someone reviews and approves your changes before they become final.
- Local repository: Our computer has a local repository that holds all the files and directories. When offline, this repository is used to make local modifications, examine the past, and commit.
- Remote Repository:
The server repository that could be found anywhere is referred to as the remote repository. Each team member uses this repository to exchange newly created changes.
The project from which you clone from is called the origin.
The SSH protocol is a method for secure remote login from one computer to another.
It is used to create a new repository in our system.
It is used initially to configure the user.name and user.email. This specifies what email id and username will be used from a local repository.
Git config -global user.name Git config -global user.email
It helps to move the changes from the working directory to the staging area.
Git add : use to add the specific file to the
Git add . : Use to add all the files to the next step.
It is use to commit all the changes in the next steps
Git commit :Once this command is run the editor will open to run the comments.
Git commit -m : It is used to commit the code with the one line comment.
It undoes changes that you’ve made to the files in your working directory
It is used to check the status of untracked and modified files on the local repository.
It shows all the branches present in the current repository.
Git branch : It is used to create a branch.
It is used to switch the branch to another branch.
Git checkout Git checkout -b : It creates a new branch and switches to that branch.
It is used to combine the changes from one branch to the another branch.
It is used to push the code to the remote repository.
It is used to fetch all the files from the remote repository to the local repository.
Working with Remote Repositories
It is employed to establish, view, and delete links to other repositories. The connections here are not like direct links into other repositories, but as bookmarks that serve as convenient names to be used as a reference.
git remote add origin
It is used to create a local working copy of an existing remote repository. The command causes the machine to download the remote repository. When working with a remote repository, it is comparable to the Git init command.
Some Advanced Git Commands
Your updated tracked files are saved using the git stash command on a list of unfinished modifications that you can apply again at any time. A developer can swap branches and work on something else without committing unfinished work by using the git stash command.
git stash: Keep untracked files alongside your current work.
git stash pop : Return work that has been stored to the working directory.
It shows the commit history order of a repository. This command helps you understand the state of your current branch by showing you the commits that lead to that state.
Git and GitHub are critical components of modern software development. They enable developers to collaborate on code, track code changes over time, and make their code available to others. Developers can work more efficiently and effectively with Git and GitHub, resulting in better code and faster development timeframes.