Skip to content

Instantly share code, notes, and snippets.

@ederrafo
Last active November 28, 2021 01:45
Show Gist options
  • Save ederrafo/408dc7304567c23f3cd549eb6a54acf4 to your computer and use it in GitHub Desktop.
Save ederrafo/408dc7304567c23f3cd549eb6a54acf4 to your computer and use it in GitHub Desktop.
git config

git-diff to ignore ^M

git-diff to ignore ^M In a project(to me happened in so win, even on diferents virtual machines :S ), something appear this caracters ^M in our scripts, for example java https://help.github.com/en/github/using-git/configuring-git-to-handle-line-endings Github suggest use the \n for end line, that you should make sure to only use \n as a newline character in git-handled repos. There's an option to auto-convert:

 $ git config --global core.autocrlf true

Se all configurations

$ git config --list

Whe git saying “old mode 100755 new mode 100644” from unstaged changes in Git?

old mode 100755  
new mode 100644  

Answer: That looks like unix file permissions modes to me (755=rwxr-xr-x, 644=rw-r--r--) - the old mode included the +x (executable) flag, the new mode doesn't.

$ git config core.filemode false

Color basico en git

$ git config --global color.ui true

Alias

 git config --global alias.co checkout
 git config --global alias.ci commit
 git config --global alias.st status
 git config --global alias.br branch
 git config --global alias.hist 'log --pretty=format:"%h %ad | %s%d [%an]" --graph --date=short'
 git config --global alias.type 'cat-file -t'
 git config --global alias.dump 'cat-file -p'
 git config --global alias.st status 
 git config --global alias.ci 'commit -v'

Add the following to the .gitconfig file in your $HOME directory.

 [alias]
  co = checkout
  ci = commit
  st = status
  br = branch
  hist = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short
  type = cat-file -t
  dump = cat-file -p
 or :
 [alias]
    st = status
    ci = commit
    co = checkout
    br = branch
    unstage = reset HEAD --
    last = log -1 HEAD

src: http://githowto.com/aliases

Evitar que git solicite y almacene ===

$ git config --global credential.helper store

Los accesos quedan almacenados en ~/.git-credentials.

$ git config --global credential.helper 'cache --timeout=3600'

ref: http://blog.openalfa.com/como-evitar-que-git-solicite-usuario-y-contrasena-cada-vez

To set your username for every repository on your computer:

 $ git config --global user.name "Billy Everyteen"
 $ git config --global user.name

To set your username for a single repository:

$ git config user.name "Billy Everyteen"
$ git config user.name

You can also check what Git thinks a specific key’s value is by typing "git config ":

$ git config user.name
$ git config user.mail

How to know the git username and email saved

The command git config --list will list the settings. There you should also find user.name and user.email.

Attention: This method saves the credentials in plaintext on your PC's disk. Everyone on your computer can access it, e.g. malicious NPM modules.

Run

git config --global credential.helper store

then

git pull provide a username and password and those details will then be remembered later. The credentials are stored in a file on the disk, with the disk permissions of "just user readable/writable" but still in plaintext.

If you want to change the password later

git pull Will fail, because the password is incorrect, git then removes the offending user+password from the ~/.git-credentials file, so now re-run

git pull to provide a new password so it works as earlier.

src https://stackoverflow.com/questions/1889559/git-diff-to-ignore-m

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment