git init
# Add
git add somefile.py
git add .
git add ../somefile.go
# Reset change to previous committed state (changes will be gone, be careful!)
git checkout file.py
# Check difference
git diff somefile.py
# Check difference on file that has been in staging
git diff somefile.py --staged
git push origin main --verbose
git checkout main
git merge --no-ff features # this will merge branch features into main
git reset HEAD~1
git checkout main
git branch -d local_branch
git push origin --delete remote_branch
If there is branch divergent between local and remote:
$ git flow feature finish refactor-predictor
Branches 'feature/refactor-predictor' and 'origin/feature/refactor-predictor' have diverged.
And local branch 'feature/refactor-predictor' is ahead of 'origin/feature/refactor-predictor'.
It means we need to resolve both branch by pulling from the remote and push it to the remote again
# Update local feature/refactor-predictor branch
git pull origin feature/refactor-predictor
# Push changes to origin
git push origin feature/refactor-predictor
If there is branch divergent, but the local may be fast-forwarded, then to resolve this we can add additional step from above
Branches 'develop' and 'origin/develop' have diverged.
Fatal: And branch 'develop' may be fast-forwarded.
# Update local develop branch
git pull origin develop
# Push changes to origin
git push origin develop
# Fast-forward develop if needed
git checkout develop
git pull origin develop --ff-only
git push origin develop
Deleted a branch but it is still showing up when you use the tab completion
git fetch --prune
This command will update your local Git repository with the latest changes from the remote repository and also remove any references to deleted branches