Skip to content

thiagohnrt/git-cmd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 

Repository files navigation

Git Command

Git Setup

Install Git

Download 🡥
Getting Started Installing Git 🡥

Identify

git config --global user.name "Thiago Honorato"
git config --global user.email thiagohonorato@example.com

SSH keys

Checking for existing SSH keys

ls -al ~/.ssh

Generating a new SSH key

ssh-keygen -t ed25519 -C "thiagohonorato@example.com"

Note: If you are using a legacy system that doesn't support the Ed25519 algorithm, use:

$ ssh-keygen -t rsa -b 4096 -C "thiagohonorato@example.com"

File .gitconfig

git config --global core.editor code
git config --global --edit

VS Code .gitconfig

Gist .gitconfig 🡥

Repository

Create a new repository

git init
git add <path|file_name>
git commit -m "message"
git branch -M <branch_name>
git remote add origin <repository>
git push -u origin <branch_name>

Push an existing repository

git remote add origin <repository>
git branch -M <branch_name>
git push -u origin <branch_name>

Clone repository with branch

git clone -b <branch_name> <repository>

Branch

Update branch

git pull origin <branch_name>

Commit and push

git add <path|file_name>
git commit -m "message"
git push origin <branch_name>

Create new branch from current branch

git checkout -b <branch_name>

Rename local branch

git branch -m <old_branch> <new_branch>
git branch -M "<new_branch>" (other way)

Merge branch

git checkout <branch_main>
git merge <branch_with_feature>

Cherry pick commit

Apply change from one branch to another.

git switch <branch_with_change>
git log
// copy commit id
git switch <branch_destiny>
git cherry-pick <commit_id>
git push origin <branch_destiny>

Reset pushed commit

git reset --hard <commit_id>
git push -f origin <branch_name>

Revert pull request

git revert -m 1 <merge_id>
git push origin <branch_name>

Delete branch

Local

git branch <branch_name> -d

Remote

git push origin -d <branch_name>

Delete all local branches except the current one

git branch | grep -v "^\*" | xargs git branch -D

Branch list

git branch -l

Commit history

git log
git log --pretty=oneline (other way)

Change Commit Message

Run the following command to amend (change) the message of the latest commit:

git commit --amend -m "New commit message."

Undo the last commit, keeping the changes

git reset --soft HEAD~1

Config

List configuration

List all variables set in config file, along with their values.

git config --list

To show the actual path where this setting is applied

git config --list --show-origin

Filename too long

git config --system core.longpaths true

About

Comandos do GIT para ajudar no fluxo do trabalho

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors