Git make a purchase, do something, and go back to the master

I have a build system that accepts a git repository, returns to a specific commit, and then loads these files somewhere. Then he returns to the master.

I am not sure that I am using the correct git commands since git will provide me with this message whenever I do a git checkout SHA :

 You are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by performing another checkout. If you want to create a new branch to retain commits you create, you may do so (now or later) by using -b with the checkout command again. Example: git checkout -b new_branch_name 

The only thing I want to do is reset my working directory to a specific commit, load these files and return to HEAD / master. I can make a few changes to the files when I go to a specific commit SHA (converts XML to JSON or something else), but I just want to lose all these changes when I return to the wizard. Right now this is my code

 git checkout SHA # do a bunch of conversion and uploading git checkout master 

Is this the preferred way to do what I want? Will I always be able to do hits from the source without any file conflicts (I don’t want everything I do between checks)?

I ask because I see "your master and origin / master diverged" several times, although I'm not sure if this is due to this.

Thanks in advance.

+4
source share
5 answers

This is normal. When the HEAD does not match the branch name, it will be shown as a separate HEAD. Nothing wrong with that.

+3
source

You can also use git show SHA1:relative/path to take a snapshot of the file at a specific point.

+1
source

You mentioned the loss of changes from the source. In your case, you can also use git reset --hard SHA1 to return to a specific commit, and then git pull missing changes from origin/master .

0
source

For description, you can simply do something like:

git archive -o / some / where / archive.tar.gz --prefix = <something> <GT commit &; <file list>

See the git archive manual for gory details. You can create zip files, tar files (compressed or inactive), pre-place the prefix β€œabove” packed files, all taken from the commit link.

0
source

This is what I use to publish API reports, test and cover code on my github page (gh-pages branch) after successfully building Bamboo. Its purpose is Ant, which does what you describe. (There are many good answers here, but posting in case this helps).

 <target name="--publish.site"> <echo file="${temp.dir}/publish-site.sh"> #!/bin/sh cd ${basedir} cp -fr ${basedir}/schema ${reports.dir} git remote set-url origin git@github.com :jasperblues/my-project.git git fetch origin gh-pages:gh-pages git checkout gh-pages git pull rm -fr ./coverage cp -fr ${reports.dir}/coverage/ ./coverage git add ./coverage rm -fr ./api cp -fr ${reports.dir}/api ./api git add api cp -fr ${reports.dir}/schema ./schema git add schema git commit -a -m "publish reports to gh-pages" git push -u origin gh-pages git checkout master </echo> <chmod perm="+x" file="${temp.dir}/publish-site.sh"/> <exec executable="${temp.dir}/publish-site.sh" failonerror="true" failifexecutionfails="true"> <env key="PATH" value="${tools.paths}"/> </exec> </target> 
0
source

All Articles