Skip to content

Latest commit

 

History

History
146 lines (127 loc) · 2.86 KB

git.md

File metadata and controls

146 lines (127 loc) · 2.86 KB

GIT commands

To Learn

https://git-school.github.io/visualizing-git/

Configurations

Creating a SSH Keys

ssh-keygen -t rsa -b 4096

Remote's commands

git remote -v
git clone -o <remote name> git@github.com:bscpaz/<repository>
git clone git@github.com:<user>/<repositorio>.git
git remote add <remote name> https://git....
git remote set-url origin git@github.com:bscpaz/<repository>
git remote remove <remote name>
git remote rename <old> <new>

Credentials configurations:

https://www.freecodecamp.org/news/how-to-fix-git-always-asking-for-user-credentials/

git config core.sshCommand 'ssh -i "/home/bscpaz/.ssh/id_rsa"'
git config --global user.name "Bruno Paz"
git config --global user.email "soujava@gmail.com"
git config --local user.name "Bruno Paz"
git config --local user.email "soujava@gmail.com"
git config --global credential.helper store
Alternative credential store:
sudo apt-get install gnome-keyring
git config --global credential.helper gnome-keyring
git config --global credential.useHttpPath true

Note: if the authentication fails, close the terminal and try again.

Show the credentials configurations:

git config --global user.name
git config --global user.email
git config --local user.name
git config --local user.email

Commons commands

Branch:

List all branches
git branch
Remove a branch
git branch -D <branch name>
Checkout to a new branch using a specific remote
git checkout -b <branch name> --track <remote>/<branch>
Checkout to a existing branch
git checkout <branch name>
Rename a existing branch
git branch -m <new name>
Check logs on a branch
git log -p .
Check logs on a file
git log -p <file-name>
See what has changed in a file
git diff <file-name>
Change commit's author
git commit --amend --author="Bruno Paz<soujava@gmail.com>"

Known issues

Issue:
  Clonning a git repository using WSL2 occurs timeout on port 22 or 443

  bscpaz@2am:/$ git clone git@github.com:bscpaz/<some-repo>
  Cloning into '<some-repo>'...
  ssh: connect to host github.com port 22: Connection timed out
  fatal: Could not read from remote repository.

  Please make sure you have the correct access rights
  and the repository exists.
  
Solution:
  - First, check if your WSL2 can run a "sudo apt-get update". If not, it's a general problem.
  - Turn off your VPN and try again.