Found 1383 Articles for Open Source

How do you view the revision history in Git?

kannan sudhakaran
Updated on 20-Feb-2021 08:48:40

1K+ Views

Let’s say you want to view all commits to the Git repository. The git log command returns all of the commits that have been made to the repository. This command lists the latest commits in chronological order, with the latest commit first.The syntax of the git log command is given below −$ git logThe following screenshot shows how to use the command to view all commits in the current repository.dell@DESKTOP-N961NR5 MINGW64 /e/tut_repo (master) $ git log commit cbc01c8399faf9063eca4ba7781d08eebbe56aaa (HEAD −> master) Author : "Kiran Date: Fri Jan 22 19:38:42 2021 +0530    file2. txt commit 8100770d7274e6bae4e252d7b3c461020b8bc5b2 Author : ... Read More

Difference between a Centralised Version Control System (CVCS) and a Distributed Version Control System (DVCS)

kannan sudhakaran
Updated on 20-Feb-2021 08:46:19

1K+ Views

A version control system is a software that allows you to manage changes to assets (codebase, files) over a period of time. Centralised and Distributed are the two main types of version control systems. The fundamental difference between these two lies in how they −Manage the repositoriesManage the content workflowCentralised ModelCentralised version control systems follow a server-client model. The server holds a single central copy of the project along with a history of changes made to the code base over a period of time. The basic workflow to work with a centralized version control system is given below −When a ... Read More

What are the best practices for committing in Git?

kannan sudhakaran
Updated on 20-Feb-2021 08:44:41

200 Views

Following are the best practices for committing in Git −Make small, single−purpose commitsCommitting small sections of code helps the team to understand what work has been completed. It is easier to revert smaller commits and helps you maintain a stable codebase. A commit should act like a wrapper around a set of changes. This means that if you are fixing 2 distinct bugs, use 2 different commits. In other words, changes or code that are logically related should be part of a single commit.Commit messages should be short and detailedCommit messages should begin with a short summary of the change. ... Read More

What are the commonly used methods to auto-generate the .gitignore file?

kannan sudhakaran
Updated on 20-Feb-2021 08:42:47

1K+ Views

The .gitignore file is a text file that tells Git which files or folders should be ignored while committing changes to the repository. This file lists the project files that we do not want Git to track for us.Following are the two commonly used methods to auto−generate the .gitignore file −Using the Github SiteThe GitHub Site provides a collection of useful .gitignore templates for different technologies. The below screenshot shows a list of .gitignore templates provided by the site.Let us say you are working on a Java project and would want to add a .gitignore file. All you have to ... Read More

How to ignore a previously committed file in Git repository?

kannan sudhakaran
Updated on 20-Feb-2021 08:39:57

4K+ Views

The .gitignore file does not operate on files that are already committed. To ignore changes to a file that was accidentally staged or committed the following should be done −Step 1 − Remove such files or directories from the staging areaStep 2 − Commit changes in the repositoryStep 3 − Add path of such files or directories in the .gitignore fileStep 4 − Commit changes to the repositoryLet us understand this with an example −Create a folder by the name “bin” in the working directory. Add a file “temp.bin” with some content inside the folder and commit the changes.$ mkdir ... Read More

What is the purpose of the .gitignore file?

kannan sudhakaran
Updated on 20-Feb-2021 08:37:13

1K+ Views

When a Git project is compiled it may generate binary files, lock files, temporary files and metadata files. These are intermediate files that are not part of the source code. For example, IDE config files or intermediate files like “.class”, ”.exe”, “.bin” etc. that are generated during compilation should be ignored by the version control system as they will be different for each developer machine and will unnecessarily increase the size of the repository.The .gitignore is a text file where each line contains a pattern for files or directories to ignore. It is usually placed at the root of the ... Read More

How to remove a committed file from the Git repository?

kannan sudhakaran
Updated on 20-Feb-2021 08:35:06

1K+ Views

Git allows you to delete a file from the repository using any of the following methods −Using the Linux rm commandUsing the git rm commandScenario 1 − Use the Linux rm commandThe syntax of the Linux rm command is −$ git rm Let us assume that a file “file1.python” exists in the repository. Use the Linux rm command to delete the file − “file1.python”.$ git rm file1.pythonLet us first verify if the file has been removed from the working directory. This can be verified by using the Linux ls command.$ lsThe output suggests that the file has been removed from ... Read More

What are the steps to rename a file in Git?

kannan sudhakaran
Updated on 20-Feb-2021 08:33:12

3K+ Views

A file can be renamed in the following two ways −Use the mv Linux commandUse the git mv commandScenario 1 − Use the Linux mv commandThe following example assumes that a file “file1.txt” exists in the repository. The syntax for using the Linux mv command is −$ mv Use the Linux command mv to rename the file to “file1.java”.$ mv file1.txt file1.javaExecute the git status command to verify the file’s status in Git.$ git statusThe output in the screenshot suggests that the file has been renamed in two steps −“file1.txt” has been deleted from the working areaA new file ... Read More

Why should you use git add command before using git commit command?

kannan sudhakaran
Updated on 20-Feb-2021 08:31:42

4K+ Views

The git add command adds files to the staging area whereas the git commit command will write changes to the repository permanently.When you have completed an important feature, you will need to create a snapshot of that change and save it to the Git repository. To achieve this, you will perform a commit.In Git, there exists an intermediate step before commit which does not exist in other version control systems. This intermediate step is called a staging area. The staging area is also known as the index. The staging area can be used to build up a set of changes ... Read More

How do you handle End-of-Line characters in Git on Windows / Linux / Mac Operating Systems?

kannan sudhakaran
Updated on 20-Feb-2021 08:29:40

2K+ Views

This question can also be rephrased as − How do you resolve the Git warning − "LF will be replaced by CRLF"?The End−of−Line is marked using two special characters "\r" in Windows Operating System while the “" character is used to mark End-of-Line in MacOS and Linux systems.The \r and are known as the Carriage Return (CR) and Line Feed (LF) characters respectively. It is important to handle End-of-Line characters properly for consistency across multiple Operating Systems.End−of−Line characters can be configured in two ways −At the time of installation −At the time of installation, Git allows us to select from ... Read More

Advertisements