Tag Archives: git

Git Warning: LF will be replaced by CRLF | fatal: CRLF would be replaced by LF

These two errors were encountered because of GIT’s newline check function.

core.safecrlf

Git provides a newline checking function( core.safecrlf ), you can check whether the file is mixed with different styles of newline at the time of submission. The options for this function are as follows:

false - Does not do any checking
warn - check on commit and warn
true - check at commit time and reject commit if a mixup is found

The most stringent true option is recommended.

core.autocrlf
if you are writing programs on windows, or if you are working with other people who are programming on windows and you are on other systems, you may encounter end of line problems. This is because Windows uses carriage return and line feed to end a line, while Mac and Linux only use line feed. Although this is a small problem, it can greatly disrupt cross platform collaboration.

Git can automatically convert line terminator CRLF to LF when you submit, and LF to CRLF when you check out code. use core.autocrlf To turn on this function. If it is on a Windows system, set it to true, so that when checking out the code, lf will be converted to CRLF:

$ git config --global core.autocrlf true

Linux or MAC systems use lf as the line terminator, so you don’t want git to do automatic conversion when checking out a file; when a file with CRLF as the line terminator is accidentally introduced, you definitely want to fix it core.autocrlf Set to input to tell git to convert CRLF to LF when submitting and not when checking out

$ git config --global core.autocrlf input

in this way, CRLF will be retained in check-out files on Windows systems, and LF will be retained on MAC and Linux systems, including warehouses.

If you are a Windows programmer and are developing a project that only runs on windows, you can set false to cancel this function and record the carriage return in the library

$ git config --global core.autocrlf false

[git] warning: LF will be replaced by CRLF

When using git in Windows 7, create a new library

git init

and then add files to the library

git add – a

but a prompt appears:

warning: LF will be replaced by CRLF ..

solution:

enter the following command in Git bash:

git config — global core.autocrlffalse (2 ‘-‘)

delete the. Git folder in the project- rf.git

re solve the problem of

git init -> “git add – a!

the following is a foreign friend’s answer in stack overflow, explaining why.

/* add at March 13, 2012*/

Git has two modes of how it treats line endings:

$ git config core.autocrlf # that command will print either "true" or "false" 

You can set the mode to use by adding an additional parameter oftrueorfalseto the above command line.

Ifcore.autocrlfis set to true, that means that any time you add a file to the git repo that git thinks is a text file, it will turn all CRLF line endings to just LF before it stores it in the commit. Whenever yougit checkoutsomething, all text files automatically will have their LF line endings converted to CRLF endings. This allows development of a project across platforms that use different line-ending styles without commits being very noisy because each editor changes the line ending style as the line ending style is always consistently LF.

The side-effect of this convenient conversion, and this is what the warning you’re seeing is about, is that if a text file you authored originally had LF endings instead of CRLF, it will be stored with LF as usual, but when checked out later it will have CRLF endings. For normal text files this is usually just fine. The warning is a “for your information” in this case, but in case git incorrectly assesses a binary file to be a text file, it is an important warning because git would then be corrupting your binary file.

Ifcore.autocrlfis set to false, no line-ending conversion is ever performed, so text files are checked in as-is. This usually works ok, as long as all your developers are either on Linux or all on Windows. But in my experience I still tend to get text files with mixed line endings that end up causing problems.

My personal preference is to leave the setting turned ON, as a Windows developer.

http://stackoverflow.com/questions/1967370/git-replacing-lf-with-crlf

Git you are not allowed to push code to protected branches on this project?

error: You are not allowed to push code to protected branches on this project.

error: failed to push some refs to …

there’s no problem – everything works as expected.

In GitLab some branches can be protected. By default only ‘master’ user can commit to protected branches.masterbranch is protected by default – it forces developers to issue merge requests to be validated by project master before integrating them into main code.

You can turn on and off protection on selected branches in Project Settings (where exactly depends on GitLab version – see instructions below).

On the same settings page you can also allow developers to push into the protected branches. With this setting on, protection will be limited to rejecting operations requiringgit push --force(rebase etc.)

I’m not really sure when this change was introduced, screenshots are from 10.3 version.

Now you can select who is allowed to merge or push into selected branches (for example: you can turn off pushes tomasterat all, forcing all changes to branch to be made via Merge Requests). Or you can click “Unprotect” to completely remove protection from branch.

source:

https://stackoverflow.com/questions/32246503/how-to-fix-you-are-not-allowed-to-push-code-to-protected-branches-on-this-proje

Git Status Warming: Your branch is ahead of ‘origin/master’ by 1 commit…

When running git status, git will compare the local branch dev with the remote branch it is tracking ( origin/Master ), because origin/Master has not been changed, it is still the 1 commit/change after the current dev branch (and origin/dev ), so a prompt will appear.

What we want to do is change the local dev branch to track the remote dev branch.

Solution (one of two options)

① , operation

git branch --set-upstream-to=origin/dev

② Add -- set upstream to the push command when pushing:

git push origin dev --set-upstream

How to Solve Git Error: Your local changes to the following files would be overwritten by merge

solve error: Your local changes to the following files would be overwritten by merge

In Berlin, we will all ignore our first suggested location files.

1 [ Sun@webserver2 demo]$ git update-index --assume-unchanged <filename&>

But the other people in Berlin, if they don’t mind installing the file, push it to Length 20179; then, when we get the code, we will be rewarded.

1

2

3

4

5

6

7

8

9

10

11

12

13

[ Sun@webserver2 demo]$ git add .

[ Sun@webserver2 demo]$ git commit -m' Falseupdate:index.php '

[master f8a7428] Falseupdate:index.php

1filechanged, 1 insertion(+), 1 deletion(-)

[ Sun@webserver2 demo]$ get pull

remote: Counting objects: 5,done.

remote: Compressing objects: 100% (2/2),done.

remote: Total 3 (delta 1), etc reused 0 (delta 0)

Unpacking objects: 100% (3/3),done.

From git.oschina.net :sunzmit/thinkphp

1bc9485..c63dff3 master -&> origin/master

error: Yourlocalchanges to the following files would be overwritten by merge:

config.ini

Consideration: your local changes will be merged with 30422nd; and you will be covered with 30422nd;

solution:

1.Removal 38144;

1 [ Sun@webserver2 demo]$ git update-index --no-assume-unchanged config.ini

2. Read the content from the latest commit, back up the current workspace content, and save the current workspace content to the Git stack

1

2

3

[ Sun@webserver2 demo]$ git stash

Saved working directory and index state WIP on master: f8a7428 Falseupdate:index.php

HEAD is now at f8a7428 Falseupdate:index.php

3pulllanguage 2017979; libraries code

1

2

3

4

[ Sun@webserver2 demo]$ give pull

Merge made by the'recursive'strategy.

config.ini .2 +-

1filechanged, 1 insertion(+), 1 deletion(-)

4.from Git26632;, read the latest saved contents, relative contents of the working area

1

2

3

[ Sun@webserver2 demo]$ give pop

Auto-merging config.ini

CONFLICT (content): Merge conflictin config.ini

_Other Organiser

1

2

3

4

5

6

7

8

[ Sun@webserver2 demo]$ vim config.ini

<<<<<<<< Updated upstream

This is atestfile!!!!!!!!!!!!!!

=======

This is atestfile

&>&>&>&>&>&> Stashed changes

[ Sun@webserver2 demo]$cattest.txt

This is atestfile

<<<<<<<< Updated upstream until======In the days of January 2017979;libraries pull 下来individuals’ contents,======to&>&>&>&>&>&>&> Stashed changesin our local files, now we can reach 21024;, except for others, just keep our contents.This is a test file

6. Copy the file to the latest version, save the contents

1

2

3

4

5

[ Sun@webserver2 demo]$ returned HEAD config.ini

Unstaged changes after reset:

Mconfig.ini

[ Sun@webserver2 demo]$cattest.txt

This is atestfile

7. Ignore and complete!

1 [ Sun@webserver2 demo]$ git update-index --assume-unchanged config.ini

8. Do not forget to delete Git26632;

1 [ Sun@webserver2 demo]$ give the stash drop

 

Your configuration specifies to merge with the ref ‘refs/heads/v.autoCheckProduct.20190325…

Question:

To create a new branch, when we execute git pull, the following error occurs

Solution:

1. switch to the main branch (or the branch you depend on, that is, from which branch you pull a new branch). Here is the master branch

2. Execute the following two commands

3. Switch to our new branch and you will be prompted

4. Execute the prompted command

5.

6。 Implementation

Git branch — set upstream to = origin/master new branch

.

7. Completion