1

I need to commit a folder, then reset anything else to the remote state and push the commit.

If I would do

git commit
git reset --hard
git push

then the git reset --hard would destroy the commit, right? how can I achieve it?

Chris Maes
  • 35,025
  • 12
  • 111
  • 136
Simon Kraus
  • 736
  • 4
  • 14
  • What is your end goal? Both your description and flow chart are indicating you want to make a commit that you'll immediately destroy.... – Simon Whitehead Jan 11 '16 at 10:37
  • i have a repo that is deployed to >10 servers. each server has a special folder in that repo that is changed by a webinterface. other servers don't touch this folder. i need a script that commits the changes from those special folders. what is the best practise to do so from server-side? – Simon Kraus Jan 11 '16 at 10:50
  • Duplicate of: http://stackoverflow.com/questions/34519665/how-to-move-head-checkout-revet-reflog-reset/34519716#34519716 – CodeWizard Jan 11 '16 at 11:00

1 Answers1

1

after performing a commit, you can safely do

git push

This will only push the commits that you made. Any unstaged or untracked changes will remain locally, you don't need to remove them.

Suppose you really want to remove them for another reason; to remove all the unstaged changes (warning: those changes will be lost!) you can do:

git checkout -- :/

if you have any untracked changes; and you don't want them to show up, you can either

  • remove those files
  • put them in the .gitignore file.
Chris Maes
  • 35,025
  • 12
  • 111
  • 136
  • thanks a lot. i had the repos messed up in some of the servers. after i cleaned up and resetted some stuff it now works as expected with a regular fetch => add => pull => commit => push cycle. – Simon Kraus Jan 11 '16 at 11:48