Skip to content

Instantly share code, notes, and snippets.

@diegozr1
Last active July 30, 2024 18:06
Show Gist options
  • Select an option

  • Save diegozr1/9b44ef0540c927c213c3049819f404ce to your computer and use it in GitHub Desktop.

Select an option

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.

fix merge conflicts

  • git checkout develop
  • git pull origin develop
  • git checkout dizamora_bug-36559930
  • git pull origin develop
  • git diff origin/develop
  • git fetch
  • git rebase origin/develop
  • git diff dbca_jsrc/src/main/java/oracle/assistants/dbca/util/DBCAConstants.java.pp
  • solve diffs
  • git add dbca_jsrc/src/main/java/oracle/assistants/dbca/util/DBCAConstants.java.pp
  • git commit -m "Fixed merge conflicts in DBCAConstants.java.pp"
  • git rebase --continue
  • git diff
  • git status
  • git diff origin/develop
  • git push origin dizamora_bug-36559930 -f

Reset branch to remove unwanted files from a PR (will remove everything)

  • git checkout <your_branch>
  • git fetch origin develop
  • git reset --hard origin/develop
  • make changes
  • git push origin YOUR_BRANCH --force

make changes

git add .
git commit -m "Convert To RAC - Create PDB service, Reset Undo Tablespace, Skip Control File Recreation"
git push origin dizamora_bug-36559930 --force

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

https://medium.com/@elton-martins/to-reset-a-git-branch-to-match-the-master-main-branch-6692c28a36fc https://www.yopa.page/blog/2023-06-19-how-to-delete-unwanted-files-from-a-pull-request.html

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