I make some changes and added a new directory to the local directory and run
git add .git commit -m "Some changes"git push origin masterNow, I wanted to:
- remove the new directory from the git, both local and server
- keep the other changes I made
git reset --soft HEAD^NOTE: Run git log -1 and you will see the last commit is "gone".
NOTE: Run git status and you will see the new directory is still added.
To remove directory which is added by previous git add .
git reset HEAD DIRECTORY_NAMENOTE: You could remove single file as well
NOTE: Run git status to confirm the directory/files are removed.
Commit again by re-using the same commit message
git commit -c ORIG_HEADPush
git push -f origin masterNOTE: Force is required, else it shall show complain of Updates were rejected because the tip of your current branch is behind its remote counterpart.
References: