Introduction
Among all distributed version control systems, Git is the most popular. Those who work on Git projects can install their repository copy locally. This capability allows collaboration between multiple contributors.
It's essential to set up Git when you first start using it. Once the setup is done on your computer, you can keep using it.
We will discuss various git First Commands in this article.
Click here to know more, wget command in linux
Git First Commands
Let us go through all of Git First commands that will make our open-source development lifecycle easier.
git fork
In Git, a fork refers to the process of a new owner taking over a repository and disconnecting the source code from previous developers. Developers often fork projects when they feel dissatisfied with the direction of the original project and want their work to remain independent. Git forks limit the ability of previous contributors to contribute to the forked repository, either by providing developers with the URL of the forked repository or by giving direct access through tools such as GitHub permissions.
First, search for the project repository you want to make changes to.

When you open that project and try to add a new file, you will get a warning that says, "You don't have write access." So here comes the fork command in the upper right corner.

After clicking on the fork, a loading screen showing Forking "project" will show a loading screen.

Now, copy the URL by clicking on the Code option.

Then open the Git Bash.

To make changes in the file, you need to clone the repository by using the command:
$ git clone https://github.com/Luxmi26/example.git
And here, you can see your local clone has been created.

Go into the new example directory, and write "$ cd example".

Let's see how we can sync this repository to the original repository.
Go to the original project on Github.
To know where our current fork is, use the command "$ git remote -v."

Next, we will add an upstream repository using
$ git remote add upstream https://github.com/Luxmi26/example.git.
Type git remote -v again to verify the upstream repository you specified for your fork. If your fork is the origin and the original repository is upstream, then the URLs for the two should be the same.

git init
To work with git on a new project, you'll need to set up a local repository. When you run the init command, you will find all of the configuration files you need to work with git in a folder named .git/. That's what git init does. A new Git repository is created and initialized with the git init command. Let's see how we can use this command.
Suppose we have a folder named Example having a text file tutorial.txt.

To set a local repository on your computer, you first need to open the git Bash and get inside the directory Example using the command "$ cd directory_location."

So, when we check the status of the directory using "$ git status," It shows that any repository is not, by default, a git repository. Still, we can convert it into a git repository using the command git init.

Therefore, writing the command ", $ git init" will initialize an empty git repository.

Again if we check the status of the Example repository, it shows that now we are on the master branch, which means we have an empty git repository.

git add
Adding changes to the next commit is indicated by "add". By using git-add, the contents of files can be indexed for commits. Git's staging area contains changes that can be placed in a new revision using the "git commit" command.
From the above scenario of the git init command, we have created an empty git repository, and when we run the command git status, it shows that we have some untracked files.

So, to track the tutorial.txt file, we need to use the command "$ git add tutorial.txt".

Now, if we check the status of the Example directory, it will no longer show that we have untracked files.

Some extra git add functionalities are:
- git add - A: All changes happen at once.
- git add: The current directory and its subdirectories are staged with new files and modifications without deletions.
- git add -u: Deletes or modifies old files but does not create new ones.
git config
The git config command sets configuration values. This command will enable your computer to create your Git name and email before you begin working with Git. This command modifies git configuration files. Information such as your username, default editor, and email is stored in these files.
There is a file named .gitconfig. To see the content of the .gitconfig file, write the command "$ cat .gitconfig". This will show the global content of the file.

Now let's make a directory using "$ mkdir test" and then list the content of the test directory and move it into the .git folder. Inside the .git folder, you can see a file named config. To see the content inside the file, we have used "$ cat config," which only shows the local data to this repository.

Now, go back to the root directory and type "$ git config –global -l" this will list the globally present content in the computer.

Let's see what else we can do with the git config command:
- We can remove any value from the file using the command
$git config –global –unset user.name

- Adding the value using the command
$git config –global user.name "value"

-
Git aliases are here to save the day if you are tired of repeating the same commands. You can use them to create shortcuts for common commands.
Let's write a git alias that calls the git commit command:
git config --global alias.com commit
Every time we run git com, the git commit command will be run.
Check out most important Git Interview Questions here.