One of my managing projects is using Git and Jenkins for deployment. In the Jenkins job they have specified a hard reset after git pull operation .I dont understand why it is using there. If there is no codes need to commit it will run the below script in jenkins
git pull origin Production
git reset --hard dbb56hgf
cp -r <jenkins_work_directory> <domain_document_root>```
CodePudding user response:
They probably want to make sure that there are no local changes before running the rest of the script.
CodePudding user response:
The purpose of the “git reset” command is to move the current HEAD to the commit specified (in this case, the dbb56hgf itself, one commit before HEAD and so on)
- git reset --hard HEAD (going back to HEAD)
- git reset --hard HEAD^ (going back to the commit before HEAD)
- git reset --hard HEAD~1 (equivalent to "^")
- git reset --hard HEAD~2 (going back two commits before HEAD)