Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Forcibly Update Existing Branch #206

Open
jhpierce opened this issue Mar 18, 2022 · 2 comments
Open

Feature Request: Forcibly Update Existing Branch #206

jhpierce opened this issue Mar 18, 2022 · 2 comments
Labels
discussion-needed enhancement New feature or request

Comments

@jhpierce
Copy link
Contributor

jhpierce commented Mar 18, 2022

Use Case

Since this library will mostly be used by automated systems, it would be useful if it could cleanly handle the case of wiping and pushing new changes to an existing branch.

One way to do that in git is:

  1. pull down the latest version of main
  2. checkout the given feature branch
  3. git reset --hard origin/main
  4. allow the user to make code changes
  5. commit the changes
  6. force push the contents to remote

Potential interface:

with force_push_to_feature_branch(branch_name):
    # Make code changes

This could raise exceptions if:

  1. There were no code changes
  2. The branch name given didn't exist

On exit, the context manager would abandon any uncommitted changes, and checkout main, leaving the repo in a clean state.

@jhpierce jhpierce added enhancement New feature or request discussion-needed labels Mar 18, 2022
@jhpierce jhpierce changed the title Forcibly Update Existing Branch Feature Request: Forcibly Update Existing Branch Mar 18, 2022
@jhpierce
Copy link
Contributor Author

jhpierce commented Apr 8, 2022

If we want to make the changes on the default branch, then forcibly push them to another branch after, then we can:

git branch -f feature_branch <default_branch>

This way, we don't need to know the branch name before the code changes are made. Taken from this SO post

@colinodell
Copy link
Collaborator

The wiping part has been implemented via #249

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion-needed enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants