Git

init

clone

mi carpeta existe

mi carpeta no existe

git init

git clone [url] origin

remote

$ git remote -v

 

$ git remote add [url] origin

 

$ git remote remove origin

story remains!

# Titulo primer nivel

## Titulo segundo nivel

 

*italic*

**bold**

 

´´´js

 

´´´

readme.md

$ touch readme.md

$ git add .

$ git commit -m "Initial commit"

$ git push origin master

readme.md

$ touch .gitignore

$ git add .

$ git commit -m "add gitignore"

$ git push origin master

.gitignore

remote

local

vs

branches

// change branch

$ git checkout feature/my-branch

 

// create new branch

$ git checkout -b feature/my-branch

 

// delete branch (local)

$ git branch -D feature/my-branch

initial commit

initial commit

branches

// sync branches

$ git --set-upstream my-branch  origin/my-branch

initial commit

stages

Working directory

staging area

repository

add

commit

initial commit

stages

$ git status

 

// add changes to stage area

$ git add .

 

$ git add src

 

$ git add src/my-file.js

initial commit

commit

// confirm changes

$ git commit -m "feat(front) add support for decimals"

 

 

// add to stage and confirm changes

$ git commit -am "feat..."

 

 

initial commit

git flow

MASTER

DEVELOP

FEATURE/MY-FEATURE

HOTFIX

initial commit

git flow

git checkout -b feature/xxx

commit 

PR

MASTER

DEVELOP

git checkout -b hotfix/xxx

initial commit

conflicts

initial commit

conflicts

$ git status

fix conflicts

$ git add 

$ git commit

initial commit

FAQ

Qué hago cuando hago un pull y tengo cambios pendientes en local?

quiero conservarlos?

no

git checkout --

si

quiero commitearlos?

si

no

git stash

git commit

initial commit

STASH

// guarda los cambios no confirmados

$ git stash save

 

// aplica los cambios del ultimo save

$ git stash apply

initial commit

FAQ

Qué hago cuando he hecho un commit mal

Lo he subido?

git reset HEAD

quiero los cambios?

si

no

--soft

--hard

no

si

me averguenzo?

si

no

git revert HEAD~2

git reset HEAD~2 --hard

git push --force

initial commit

Git intro

By Jon Rojí

Git intro

  • 1,003