Skip to content

Instantly share code, notes, and snippets.

@dre3s
Last active November 10, 2016 19:22
Show Gist options
  • Select an option

  • Save dre3s/0acb3367918e255d14a7feb6ee6ca1c9 to your computer and use it in GitHub Desktop.

Select an option

Save dre3s/0acb3367918e255d14a7feb6ee6ca1c9 to your computer and use it in GitHub Desktop.
git.utils.daily

#Reset

Voltar como estava no remote

$ git reset --hard origin/master

#Merge

Fazer merge de um arquivo específico

$ git checkout source_branch -- <paths>...

Merge da branch local(master) com uma remote(other_branch) dando prioridade para remote

$ git merge --strategy recursive -X theirs $BRANCH

#tags

Deletar tag local

$ git tag -d <TAG_NAME>

Deletar tag do remote

$ git push --delete origin <TAG_NAME>

delete branch

$ git branch -D <branchName> && git push origin :<branchName>

local

$ git branch -D <branchName>

remote

$ git push origin :<branchName>

Delete a list of branhes

delete_branch() {                                                                          
  for BRANCH in "$@"                                                                       
  do                                                                                       
    echo "$BRANCH"                                                                         
    git branch -D $BRANCH && git push origin :$BRANCH         
    # play sound of the ubuntu os
    paplay /usr/share/sounds/ubuntu/stereo/dialog-error.ogg                                
  done                                                                                     
}   

Fetch all branches of the remote

git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done
git fetch --all
git pull --all

alias to merge strategy

Ex: merge_theirs master
Ex: merge_theirs otherBranch

merge_theirs() {                                                                           
  BRANCH=$1                                                                                
  git merge --strategy recursive -X theirs $BRANCH                                         
}   
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment