In this article, you can learn different errors faced while working with git.
1. fatal: refusing to merge unrelated histories
If you get this error, you can use the command “–allow-unrelated-histories” to solve it.
git pull origin master --allow-unrelated-histories
2. file path too long error
Above error can be resolved by using below command.
git config --system core.longpaths true
Command to set name and email in git:
git config –global user.name “Ronan”
git config –global user.email “email@example.com”
To see the global configuration settings.
git config –global –list
git saves settings in this config file.
Command to create a repository:
git init project1
Output: Initialized empty Git repository in C:/Users/Ronan/project1/.git/
Command to know whether git is tracking a file or not?
Command to add file in git.
git add filename.extension
This command adds file to the staging area.
Command to commit changes in git.
git commit -m “first commit”
Commits all files present under staging area.
-m is the parameter to provide commit message name.
git add file1.txt
git commit -m “second commit”
Above two operations can be done in single line as below.
git commit -am “second commit”
In -am: a is to add file and m is to provide commit message.
We have few new files in the directory and how do we add it to staging area in a single command?
git add .
Command to see all the commits in one line.
git log –oneline –graph –decorate –color
Command to remove a file in git.
git rm filename
Command to create a directory.