Skip to content

Instantly share code, notes, and snippets.

@diegozr1
Last active July 5, 2024 05:22
Show Gist options
  • Save diegozr1/9b44ef0540c927c213c3049819f404ce to your computer and use it in GitHub Desktop.
Save diegozr1/9b44ef0540c927c213c3049819f404ce to your computer and use it in GitHub Desktop.
Github commands & tricks

Github tricks

update my branch with last changes from develop branch

  • ensure all changes in your branch are commited
  • git fetch
  • git rebase origin/develop

view diffs from my branch to an specific branch

  • git diff origin/develop

make changes to an existing commit to update a branch

  • git rm <path to file> - removes unrequired files before commiting
  • git checkout origin/develop <path to file> - resets files to previous state after commiting
  • git commit -am "new changes" - sends new commit with appending changes

reset current branch

  • git reset --hard <remote>/<branch_name>

no merging, no rebasing, simply put the local branch to exactly the same state as the remote is.

References

https://stackoverflow.com/questions/37972753/git-reset-single-file-in-feature-branch-to-be-the-same-as-in-master-main https://stackoverflow.com/questions/3876977/update-git-branches-from-master https://stackoverflow.com/questions/12481639/remove-file-from-latest-commit https://stackoverflow.com/questions/39399804/updates-were-rejected-because-the-tip-of-your-current-branch-is-behind-its-remot

https://stackoverflow.com/questions/3876977/update-git-branches-from-master https://stackoverflow.com/questions/10641361/get-all-files-that-have-been-modified-in-git-branch https://stackoverflow.com/questions/39459467/remove-a-modified-file-from-pull-request https://stackoverflow.com/questions/3876977/update-git-branches-from-master https://stackoverflow.com/questions/11356460/how-to-cleanly-get-copy-a-remote-git-branch-to-local-repository https://stackoverflow.com/questions/61212/how-do-i-remove-local-untracked-files-from-the-current-git-working-tree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment