To start working with Git, you require to make your computer suitable for handling Git. That’s why you need to install Git on your computer. Let’s see how to install and configure Git. (complete git guide for beginners)
Click here to download the Git package.
Click on the downloaded file to install it.
There are several ways to install Git for different Linux distros. But very easy. Type the following commands in the terminal according to the distro.
Debian / Ubuntu
$ apt-get install git
um yum install git
$ emerge –ask –verbose dev-vcs / git
$ pacman -S git
cd / usr / ports / devel / git
Solaris 11 Express
$ pkg install developer / versioning / git
$ pkg_add git
The principal purpose of configuring GIT is that when you commit through GIT, it will store your information with Commit. All you have to do is enter your username and email address during the configuration. (complete git guide for beginners)
After installing Git, a shortcut file named gitBash will be generated on the computer desktop. Please open it and write the following commands in it. Linux users can type commands in the terminal.
Git config – global user.name “Your Name Here”
Enter your name in place of Your Name Here.
git config – global user.email “[email protected]”
The email address you enter here must match the email address of your server account.
Now your computer is ready to use Git. From now on, you can use Git commands on your computer.
We will write all our commands in gitBash or terminal.
There are some servers for storing Git repositories online. Github, bitbucket is one of them. Repositories stored on these servers are called remote repositories. You can create your personal repository by accessing the sites. After creating a remote repository, you normally require to edit them from your local computer. After editing, you have to upload it to the remote repository again. Let’s see how we can edit a remote repository working Git.
(We will discuss bitbucket and web development repositories here)
- First, you require to bring your remote repository to your individual computer. To do this, you require to go to the localhost of your computer using the cd command. For localhost, you need to enter the htdocs or www folder.
- Enter your remote repository through the browser. After clicking the clone switch there, you will see a command. The clone command has two options. One is HTTPS, and the other is ssh. Selecting the ssh command will create an ssh key on your computer. You need to save it to your server later. But if you select HTTPS, you don’t have to create any key. Let’s see how to create ssh key-
=> Enter the ssh-keygen command in the terminal. This will create a .ssh folder hidden in your computer’s home folder and create an id_rsa.pub file. Open the id_rsa.pub file and copy the text inside it.
=> Log in to your server account. From there, enter the manage account link. Then from there, enter the ssh key link and paste your key. Then save and come out.
- Copy the clone command from the server account and paste it into the terminal.
- If your clone command is HTTPS, then you will be asked for your account username and password. With the correct information, your server’s repository will be cloned to your individual computer. When you enter your localhost, you will scan a folder named Server Repository. This is a clone of a remote repository on your personal computer.
- Now work in your repository offline. Whenever you require to attach your code to your remote repository, you require to use some commands. They are given below.
=> Every time your repository relinquishes a stable state, they need to be sent to the Staging Area. Sending to the staging area means producing a list of the files you will surely include in the repository. For that, you require to use the git add command. If you want to add all the existing files to the Staging area, you require to use the git add * command. If you want to add a file, you must enter the file’s name behind the git adds command. Suppose you have created a file named test.txt that you want to send to the Staging area. Then your command will be git add test.txt.
=> Be positive to attach the files attached to your staging area to the primary repository. For that, you need to manage the git commit command. You need to attach a message to each commit. Then your complete command will be-
git commit -a -m “Your Message”
=> Now, you require to use the git push command to attach the committed files to the remote repository. You requirement also specify which branch (branch (branch will be discussed in another tutorial))). We will add our file to the master branch. The complete command is given below.
git push origin master
Here origin is the name of the remote repository. The name of the remote repository from which the file is cloned is normally given as origin.
Follow the steps below to use Git Repository offline.
- Obtain your repository utilising cd. Suppose, if you need to create a routine management operation, and the name of your repository folder is RMS, then enter the rms directory with the cd command.
- Presently type the git init command. This will make your repository helpful for git and create a hidden folder called .git. If the .git folder is not created in your repository, you will not use the git commands.
- Your repository is now fit for work. You can now create, edit, and delete any file or folder.
- Every time your repository reaches a stable state, they need to be moved to the Staging Area. Sending to the staging area means making a list of the files you will positively include in the repository. For that, you require to use the git add command. If you want to add all the existing files to the Staging area, you require to use the git add * command. If you want to attach a file, you must enter the file’s name after the git adds command. Suppose you have created a file called test.txt that you want to send to the Staging area. Then your command will be git add test.txt.
- The last thing you require to do is securely add the files attached to your staging area to the main repository. For that, you need to use the git commit command. You must attach a message to the individual commit. Then your complete command will be-
git commit -a -m “Your Message”.
complete git guide for beginners | complete git guide for beginners | complete git guide for beginners