Show informations about remote branches:
git remote show origin
Stop tracking deleted remote branches:
git remote prune origin --dry-run
Verify origin and upstream setup:
git remote -v
If upstream is missing, setup:
git remote add upstream [email protected]:some-gatekeeper-maintainer/some-project.git
Collect changes of upstream repository:
git fetch upstream
Checkout main branch (master):
git checkout master
And continue usual workflow:
git pull upstream master || $ git merge upstream/master || $ git rebase upstream/master
Look to log for what you lost:
git reflog
Create new branch from what you found:
git checkout -b branch-name 70b3696
To keep changes:
git reset HEAD
To remove everything not commited permanently:
git reset --hard HEAD
To reset changes to specific origin branch:
git fetch origin
git reset --hard origin/master
git rm -r --cached .
git add .
start interactive rebase as many commits backward as you need
git rebase -i HEAD~8
and in message alter details of specific commits with command on next line after wanted commit pick
pick a37d264 PHPSPEC-1 Install
exec GIT_COMMITTER_DATE="Thu Jan 9 18:12:51 2020 +0000" git commit --amend --no-edit --date "Thu Jan 9 18:12:51 2020 +0000" --author="Peter Labos <[email protected]>"
this change may require force push
Use last coorrect commit hash
git rebase -i f10cc70c049a297bbd05552c62d591ff96c41836 -x "git commit --amend --author 'Peter Labos <[email protected]>' -CHEAD"
git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done
git fetch --all
git pull --all