Code Monkey home page Code Monkey logo

git-cmd's Introduction

GIT Command

Git Setup

Install Git

Download 🡥
Getting Started Installing Git 🡥

Identify

git config --global user.name "Thiago Honorato"
git config --global user.email [email protected]

SSH keys

Checking for existing SSH keys

ls -al ~/.ssh

Generating a new SSH key

ssh-keygen -t ed25519 -C "[email protected]"

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

$ ssh-keygen -t rsa -b 4096 -C "[email protected]"

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>

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."

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

git-cmd's People

Contributors

thiagohnrt avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.