jesuspinar / git

Cheatsheet that helps with git-cli commands.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Git introduction

Beginners guide that helps with git commands.

Global config

Add your name.
git config --global user.name "Your name"
Add your email.
git config --global user.mail "name@email.com"
Adds default text editor.
git config --global core.editor "code --wait"
Opens config settings.
git config --global -e
Specify the return type just one enter. Linux|Mac
git config --global core.autocrlf input
Specify the return type just one enter. Windows
git config --global core.autocrlf true
See other options.
git config -h

Usefull commands

Initializes a git repo in local folder.
git init
Adds all changes to stage (deleted, modified and new files or dirs).
git add .
Make a commit and specify a message.
git commit -m "Initial commit"
Delete file or dir from the working tree the file.
git rm file
Renaming or moving files or dirs.
git mv filename filename
Shows the changes at stage.
git status
Shows the changes at stage, clean.
git status -s
Compare the changes.
git diff
Compares the changes on stage.
git diff --staged
Review the commit history of the repository.
git log
Review the commit history repo, clean.
git log --oneline
Shows the actual brach.
git branch
Shows local and remote branches and info.
git branch -vva
Creates a new branch.
git checkout -b name
Deletes a local branch.
git branch -d branchName
git branch --delete branchName
Changes to branch .
git switch branchName
Add changes of branchName to current branch.
git merge branchName
Indicates remote server to push changes.
git remote add origin www.github.com
Publishes the changes into branchName at repo on the server.
git push origin branchName
Publishes the changes into branch main if local and remote branch name are different.
git push origin branchLocalName:branchRemoteName
Creates a branch main and publishes changes into it at repo on the server.
git push -u origin main
Show, remove , rename the remote repos
git remote -v 
git remote rm name 
git remote remove name newname 
After pulling shows changes .
git whatchanged

About

Cheatsheet that helps with git-cli commands.