The Git tutorial

Git tutorial

What is Git?

Git is a free and open source software for version control, that is designed to handle all kinds of projects.

Advantages of Git

For example, let’s consider people A and B working on the same …


This content originally appeared on DEV Community and was authored by We FOSS

Git tutorial

What is Git?

Git is a free and open source software for version control, that is designed to handle all kinds of projects.

Advantages of Git

For example, let's consider people A and B working on the same project. Let's assume they are editing the same file.

If A adds some text, and B replaces some text, a problem arises. The same file is being edited by 2 people, and there arrives a clash. The text replaced by B could be one of the dependencies of A's text.

Git was introduced into this world, to solve this problem. One can edit the file, the other can also do the same, but these kinds of errors won't occur.

Installing Git

You can install git via checking out this URL: https://git-scm.com/downloads, and then selecting your operating system. Alternatively,

  • If your're using Chocolatey in Windows, open Powershell as admin and run this: choco install git -y
  • If you're using Linux, run this (according to your distro):
  sudo apt install git -y (Debian based)
  sudo pacman -Sy git (Arch based)
  sudo yum install git -y (RedHat/Fedora based)
  • If you're using macOS with HomeBrew installed, use this command: brew install git

And now, you're ready to use Git.

Using Git

Using Git via the GUI offered by GitHub seems easier, but learning the command line is even more easier and it helps you a lot.

Here's how you can use Git with the command line:

  1. git clone url_of_repo (To clone the repository into your system)
  2. git checkout branch_name
    (to change to a separate branch)
    git checkout -b branch_name (to create a new branch and switch to it)

  3. You can create a file after changing the branch, or make any changes to already existing files.

  4. After editing/modifying the files, you have to push the changes to GitHub.

Note: For the following commands to work, you must be inside that prticular folder. Else, it won't work :)

  1. Use "git add ." ( Here, period is used to push all the files) or git add -A (same purpose)

  2. git commit -m your_message (to )

  3. git push (to push your changes to the repository)

    This might not work during a few situations, so you can use the command which is recommended by Git to use in the terminal.

And, those are the basic methods to use Git. If you master these 5 commands, you won't be needing the GUI to manage files via GitHub.

Good Luck!

Credits:

Authors: Yash Wankhade and Abhay Anand

Editors: Tushar Verma, Pranav and Rasheedah

Publisher: Pranav P


This content originally appeared on DEV Community and was authored by We FOSS


Print Share Comment Cite Upload Translate Updates
APA

We FOSS | Sciencx (2021-06-06T17:34:58+00:00) The Git tutorial. Retrieved from https://www.scien.cx/2021/06/06/the-git-tutorial/

MLA
" » The Git tutorial." We FOSS | Sciencx - Sunday June 6, 2021, https://www.scien.cx/2021/06/06/the-git-tutorial/
HARVARD
We FOSS | Sciencx Sunday June 6, 2021 » The Git tutorial., viewed ,<https://www.scien.cx/2021/06/06/the-git-tutorial/>
VANCOUVER
We FOSS | Sciencx - » The Git tutorial. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/06/06/the-git-tutorial/
CHICAGO
" » The Git tutorial." We FOSS | Sciencx - Accessed . https://www.scien.cx/2021/06/06/the-git-tutorial/
IEEE
" » The Git tutorial." We FOSS | Sciencx [Online]. Available: https://www.scien.cx/2021/06/06/the-git-tutorial/. [Accessed: ]
rf:citation
» The Git tutorial | We FOSS | Sciencx | https://www.scien.cx/2021/06/06/the-git-tutorial/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.