How can I do git pull and git checkout correctly?

I am working on an assembly that is currently doing the following:

After the git repository has been initialized and checked out to a specific revision, I need to pull out a commit that will act in time, apply and then build.

Currently, the commands I run in my build script are as follows:

git pull --rebase origin master
git checkout [ID I want]
git submodule update
[Build command]

      

However, when I run this twice, I get "Detected patch" back "(or previously applied)! Acquire -R? [N]" in many files. I can add "git reset --hard HEAD ^" as the first line, but I wouldn't have to rebuild the whole project from scratch every time.

Is there a good way to allow the build command to run without having to rebuild everything and also not get a reverse patch detected message?

+3


source to share


1 answer


As mentioned in the comments, if you need a hard reset, but you want not to check all files as quality git reset --hard

, by resetting the changed timestamps of each file, you can do a soft reset and then check the file:

git reset --soft HEAD^
git checkout -- .

      



Checking a file only checks those files that have changed, and a soft reset still resets the pointer to the target commit.

+1


source







All Articles