Skip to content

Instantly share code, notes, and snippets.

@johnatanbrayan
Last active October 15, 2021 02:22
Show Gist options
  • Save johnatanbrayan/a5ef4a58fca50affb7b257e63cb0141e to your computer and use it in GitHub Desktop.
Save johnatanbrayan/a5ef4a58fca50affb7b257e63cb0141e to your computer and use it in GitHub Desktop.
Git and Git Flow commands
# Deletes all created files and directories
git clean -fd
# Undoes all changes by returning to the last recorded appointment
git reset --hard
# Remote branch list
git branch -r
# Put all files on stage area to commit
git add .
# Put on stage area and commit
git commit -am "Working auto"
# Edit last Commit
git commit --amend
# Edit last Commit and push new things on last commit
git commit --amend --no-edit
# Remove files from stage area
git add -u
# Don't include file on stage area
git add -- file.txt
# Link to a repository
git remote add nameLink https://github.com/repository/myApp.git
# Link to a repository on heroku
git remote add heroku git@heroku.com:project.git
# Remove a remote link
git remote rm <remote-name>
# List all remote link
git remote -v
# Set username local on repository
git config user.name "usernameLocal"
# Set email local no repository
git config user.email "usernameLocal@gmail.com"
# Set username global by default on all repositories
git config --global user.name "usernameGlobal"
# Set email global by default on all repositories
git config --global user.email "usernameGlobal@gmail.com"
# Put auto password on git config
git config --global credential.helper store
# Local branch list
git branch
# Branch exchange
git checkout name-of-other-branch
# Change to last branch changed
git checkout -
# Rename branch
git checkout -m <newnamebranch>
# If files have been added to the repository, you need to remove them
git rm --cached -r /.nomeDoArquivo
# Deletes the local branch
git branch -D localBranchName
# Download remote branche to locally
git checkout -b name-of-branch origin/name-of-branch
# Create a branch from a commit hash
git checkout -b branchname <sha1-of-commit or HEAD~3>
# Create a new branch
git checkout -b branchname
# Push a branch on gitHub or gitLab
git push --set-upstream origin nameBranch
# Push a release on github or gitlab
git push --tags
# Push a subfolder how origin project
git subtree push --prefix folder-backend heroku main
# Make a merge on a branch
git merge nameOtherBranchToThatBranch
# Load all remote branchs
git fetch -p
git fetch --all
git pull --all
# Configure and Inicializing git flow on project
git flow init
# Force configure git flow
git flow init -f
# Create new Branch with git flow
git flow feature start name-of-new-branch
# Finish branch with git flow and merge to default branch
git flow feature finish name-of-new-branch
# Start a new release on master
# Execute this command below on branch dev
git flow release start 0.0.4
# Change the version of pom.xml
# Change the version of package.json
# Finish a new release on master
git flow release finish 0.0.4
# It is the act of selecting one commit from the branch and applying it to the other
git cherry-pick ~sha-idcommit
# Reset frontend
git checkout src/main/webapp/*
git checkout src/test/javascript/*
git clean -fd src/test/javascript/*
# How to delete node_modules in terminal
npx npkill
# List commits summed up
git log --oneline
# Show commits with graph
git log --graph --oneline --decorate
# How to push things on cache
git stash
# How to push things on cache with alias name
git stash save aliasname
# List all on cache
git stash list
# Get things on cache
git stash apply aliasname
# Viewing the file modified
git stash show
# Creating a branch from the stash
git stash branch <branch_name> <stash_id>
# Remove your stash by a id
git stash drop <stash_id>
# Remove all stash
git stash clear
## Heroku
# Deploy on a branch on heroku
git push heroku yourbranch:master
# Deploy on master
git push heroku master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment