简体   繁体   中英

Git - files from committed and pushed changes need to be uncommitted

On a separate branch as a pull request I have committed and pushed some system and project environment files. They cause huge issues for other developers because they are my system files interfering with their system files. How can I remove those files from that PR?

Suppose you modified the files on my-branch~3:

git checkout my-branch~3
git checkout HEAD~1 -- some-file.txt some-file2.txt
git commit --amend --no-edit # amend revision, those files will be as they were on previous revision
git cherry-pick my-branch~3..my-branch # rewrite remaining history of branch
# check the branch to make sure everything is of
# if it is... continue with the recipe
git branch -f my-branch #move branch pointer to new rewritten branch
git checkout my-branch
git push --force origin my-branch # adjust name of branch and remote

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM