Git Setup: Overcome Version Control Challenges in 3 Easy Steps

Setting up a New Code Repository

git-version-control
git-version-control
  1. Install GIT
    – visit website:  Git Download
  2. To check Wether GIT is installed
    git  – – version 
  3. Configure GIT – This is important for version control system, as each GIT commit uses this information.eg- git config – – global user.name “your_name”
           git config – – global user.email “your_email”

    Note – Use global to set username and e-mail for every repository on your computer. If you want to set username/email for just the current repo, you can remove Global.

  4. Creating GIT folder – Now let’s create a new folder for our project.
    mkdir folder_name   (mkdir stands for make a new directory)
    cd folder_name   ( cd changes to the current working directory.)
  5. Initialize GIT – Once you have navigated to the correct folder, you can initialize GIT on that folder :
     git init
     Initialized empty Git repository in directory_path
  6. Open Path – Once you initilized Git, u have to open the directory in the code editor (can use any code editor like – vs code, Eclipse etc.) and can create project files (for example add.java)

Git Staging Environment

git-version-control
git-version-control

The files that you created on the editor in the directory are ready to be committed to the repository.
 git add add.java

Adding more than one file

lets add two files this time at once. Create 2 more files in the editor lets assume the name as divide.java and multiply.java
Now lets add both of them into the repository

git add –all

using –all instead of file name will stage all files from the project.
to check weather files are staged or not we use status.

git status

Git Commit

Git commit is like saving your work. When you make changes to your code, you can “commit” those changes to create a new version of your project. This helps you keep track of what you’ve done and allows you to go back to previous versions if needed.

NOTE – While using commit, we should always include a message.
By adding a clear message to each commit, it is clear for yourself and others to see what was changes and when.

git commit -m “First programme”

Git Commit Log

To view the history of commits for a repository, you can use the log command:

git log

 

 

want to read more git content –Click Here