Skip to content

Instantly share code, notes, and snippets.

@alexlopes
Last active September 6, 2018 00:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexlopes/1e6a827be88cdd98633b to your computer and use it in GitHub Desktop.
Save alexlopes/1e6a827be88cdd98633b to your computer and use it in GitHub Desktop.
git_tricks

Deletin branches

Deleting local branches in Git

git branch -d feature/login

Deleting remote branches in Git

git push origin --delete feature/login

Update fork-branch according to original repo

https://help.github.com/articles/syncing-a-fork/

pushing to multiple remotes (BitBucket + OpenShift)

http://stackoverflow.com/questions/12657168/can-i-use-my-existing-git-repo-with-openshift

clone specific branch

git clone -b mybranch --single-branch git://sub.domain.com/repo.git

get remote branch

cria branch

git branch nome_branch_local

entrar na branch

git checkout bortollv_31

referenciando no remote

git branch -u origin/bortollv_31

atualizar local

git fetch git pull

clone with explicit login

git clone https://username:token@github.com/username/repository.git

How can I see what I am about to push with git?

git diff --stat --cached origin/master

How do I delete unpushed git commits?

Delete the most recent commit, keeping the work you've done:

git reset --soft HEAD~1 Delete the most recent commit, destroying the work you've done:

git reset --hard HEAD~1

Reset credentials

You could also disable use of the Git credential cache using git config --global --unset credential.helper. Then reset this, and you would continue to have the cached credentials available for other repositories (if any). You may also need to do git config --system --unset credential.helper

Errors

Problem after clone

gnutls_handshake() failed: Access was denied

Solution is set proxy for git

git config --global http.proxy

Migrate old-repo to new-repo

git clone --bare git@github.dxc.com:org/old-repository.git

cd old-repository.git

git push --mirror git@github.dxc.com:org/new-repository.git
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment