How to get the modified files(before and after) from git version server?

 Clash Royale CLAN TAG#URR8PPP
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
Now here is the commit id 41f9f4e392ab50db264e0328de7d69f1f10646eb, I want to get this commit id code which were modified only.
I use git show 41f9f4e392ab50db264e0328de7d69f1f10646eb to see modified files, how can I download these both after modified and before modified version via Linux git command? In a word, I just want to compare the differences from before and after commit id 41f9f4e392ab50db264e0328de7d69f1f10646eb to merge code easily. 
Any idea will be helpful, thanks in advance.
linux git diff
add a comment |Â
up vote
1
down vote
favorite
Now here is the commit id 41f9f4e392ab50db264e0328de7d69f1f10646eb, I want to get this commit id code which were modified only.
I use git show 41f9f4e392ab50db264e0328de7d69f1f10646eb to see modified files, how can I download these both after modified and before modified version via Linux git command? In a word, I just want to compare the differences from before and after commit id 41f9f4e392ab50db264e0328de7d69f1f10646eb to merge code easily. 
Any idea will be helpful, thanks in advance.
linux git diff
 
 
 
 
 
 
 If you want to compare what's different,- git showalready shows the differences. Why do you need the files?
 â muru
 Jan 31 at 4:02
 
 
 
 
 
 
 
 
 
 stackoverflow.com/questions/610208/â¦
 â cas
 Jan 31 at 4:10
 
 
 
 
 
 
 
 
 
 @ muru I need to get the midified files(before & after) then compare them, and merge them to another code branch, so I need the modified(before & after) files.
 â Huang
 Jan 31 at 4:33
 
 
 
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
Now here is the commit id 41f9f4e392ab50db264e0328de7d69f1f10646eb, I want to get this commit id code which were modified only.
I use git show 41f9f4e392ab50db264e0328de7d69f1f10646eb to see modified files, how can I download these both after modified and before modified version via Linux git command? In a word, I just want to compare the differences from before and after commit id 41f9f4e392ab50db264e0328de7d69f1f10646eb to merge code easily. 
Any idea will be helpful, thanks in advance.
linux git diff
Now here is the commit id 41f9f4e392ab50db264e0328de7d69f1f10646eb, I want to get this commit id code which were modified only.
I use git show 41f9f4e392ab50db264e0328de7d69f1f10646eb to see modified files, how can I download these both after modified and before modified version via Linux git command? In a word, I just want to compare the differences from before and after commit id 41f9f4e392ab50db264e0328de7d69f1f10646eb to merge code easily. 
Any idea will be helpful, thanks in advance.
linux git diff
edited Jan 31 at 4:45


galoget
36319
36319
asked Jan 31 at 3:57
Huang
184
184
 
 
 
 
 
 
 If you want to compare what's different,- git showalready shows the differences. Why do you need the files?
 â muru
 Jan 31 at 4:02
 
 
 
 
 
 
 
 
 
 stackoverflow.com/questions/610208/â¦
 â cas
 Jan 31 at 4:10
 
 
 
 
 
 
 
 
 
 @ muru I need to get the midified files(before & after) then compare them, and merge them to another code branch, so I need the modified(before & after) files.
 â Huang
 Jan 31 at 4:33
 
 
 
add a comment |Â
 
 
 
 
 
 
 If you want to compare what's different,- git showalready shows the differences. Why do you need the files?
 â muru
 Jan 31 at 4:02
 
 
 
 
 
 
 
 
 
 stackoverflow.com/questions/610208/â¦
 â cas
 Jan 31 at 4:10
 
 
 
 
 
 
 
 
 
 @ muru I need to get the midified files(before & after) then compare them, and merge them to another code branch, so I need the modified(before & after) files.
 â Huang
 Jan 31 at 4:33
 
 
 
If you want to compare what's different,
git show already shows the differences. Why do you need the files?â muru
Jan 31 at 4:02
If you want to compare what's different,
git show already shows the differences. Why do you need the files?â muru
Jan 31 at 4:02
stackoverflow.com/questions/610208/â¦
â cas
Jan 31 at 4:10
stackoverflow.com/questions/610208/â¦
â cas
Jan 31 at 4:10
@ muru I need to get the midified files(before & after) then compare them, and merge them to another code branch, so I need the modified(before & after) files.
â Huang
Jan 31 at 4:33
@ muru I need to get the midified files(before & after) then compare them, and merge them to another code branch, so I need the modified(before & after) files.
â Huang
Jan 31 at 4:33
add a comment |Â
 2 Answers
 2
 
active
oldest
votes
up vote
3
down vote
To see the state of files before and after a given commit, check out its parent:
git checkout 41f9f4e3~1
then the commit itself:
git checkout 41f9f4e3
However, itâÂÂs hardly ever necessary to look at details of a change in this way. In your case, to apply a commit to another branch, cherry pick it:
git checkout $target_branch
git cherry-pick -x 41f9f4e3
(replacing $target_branch as appropriate). The -x option adds a comment in the commit message with the origin of the cherry-pick.
add a comment |Â
up vote
1
down vote
accepted
Thanks all, I have found the correct way, here it is.
#!/bin/bash
from_id=$1
to_id=$2
#echo $from_id
#echo $to_id
diffpath='patch/diff.log'
newpath='patch/new/'
oldpath='patch/old/'
rm -rf patch
mkdir -p $newpath
mkdir -p $oldpath
git diff $from_id $to_id --raw > $diffpath
cat $diffpath | while read line
do 
 #echo =====================================
 #echo $line
 OLD_IFS="$IFS"
 IFS=" "
 arr=($line)
 IFS="$OLD_IFS" 
 #echo $arr[4]
 filepath=$arr[4]##* 
 #echo $filepath
 newid=$arr[2]%%...
 #echo $newid
 oldid=$arr[3]%%...
 #echo $oldid 
 if [ "$newid"x != "0000000"x ]; then 
 newfilepath=$newpath$filepath
 echo $newfilepath
 dirpath=$newfilepath%/*
 echo $dirpath
 mkdir -p $dirpath
 git cat-file -p $newid > $newfilepath
 fi
 if [ "$oldid"x != "0000000"x ]; then 
 oldfilepath=$oldpath$filepath 
 echo $oldfilepath
 dirpath=$oldfilepath%/*
 echo $dirpath 
 mkdir -p $dirpath
 git cat-file -p $oldid > $oldfilepath
 fi 
done 
You will found the new directory named patch in current working directory after doing this.
add a comment |Â
 2 Answers
 2
 
active
oldest
votes
 2 Answers
 2
 
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
To see the state of files before and after a given commit, check out its parent:
git checkout 41f9f4e3~1
then the commit itself:
git checkout 41f9f4e3
However, itâÂÂs hardly ever necessary to look at details of a change in this way. In your case, to apply a commit to another branch, cherry pick it:
git checkout $target_branch
git cherry-pick -x 41f9f4e3
(replacing $target_branch as appropriate). The -x option adds a comment in the commit message with the origin of the cherry-pick.
add a comment |Â
up vote
3
down vote
To see the state of files before and after a given commit, check out its parent:
git checkout 41f9f4e3~1
then the commit itself:
git checkout 41f9f4e3
However, itâÂÂs hardly ever necessary to look at details of a change in this way. In your case, to apply a commit to another branch, cherry pick it:
git checkout $target_branch
git cherry-pick -x 41f9f4e3
(replacing $target_branch as appropriate). The -x option adds a comment in the commit message with the origin of the cherry-pick.
add a comment |Â
up vote
3
down vote
up vote
3
down vote
To see the state of files before and after a given commit, check out its parent:
git checkout 41f9f4e3~1
then the commit itself:
git checkout 41f9f4e3
However, itâÂÂs hardly ever necessary to look at details of a change in this way. In your case, to apply a commit to another branch, cherry pick it:
git checkout $target_branch
git cherry-pick -x 41f9f4e3
(replacing $target_branch as appropriate). The -x option adds a comment in the commit message with the origin of the cherry-pick.
To see the state of files before and after a given commit, check out its parent:
git checkout 41f9f4e3~1
then the commit itself:
git checkout 41f9f4e3
However, itâÂÂs hardly ever necessary to look at details of a change in this way. In your case, to apply a commit to another branch, cherry pick it:
git checkout $target_branch
git cherry-pick -x 41f9f4e3
(replacing $target_branch as appropriate). The -x option adds a comment in the commit message with the origin of the cherry-pick.
answered Jan 31 at 5:18
Stephen Kitt
142k22308370
142k22308370
add a comment |Â
add a comment |Â
up vote
1
down vote
accepted
Thanks all, I have found the correct way, here it is.
#!/bin/bash
from_id=$1
to_id=$2
#echo $from_id
#echo $to_id
diffpath='patch/diff.log'
newpath='patch/new/'
oldpath='patch/old/'
rm -rf patch
mkdir -p $newpath
mkdir -p $oldpath
git diff $from_id $to_id --raw > $diffpath
cat $diffpath | while read line
do 
 #echo =====================================
 #echo $line
 OLD_IFS="$IFS"
 IFS=" "
 arr=($line)
 IFS="$OLD_IFS" 
 #echo $arr[4]
 filepath=$arr[4]##* 
 #echo $filepath
 newid=$arr[2]%%...
 #echo $newid
 oldid=$arr[3]%%...
 #echo $oldid 
 if [ "$newid"x != "0000000"x ]; then 
 newfilepath=$newpath$filepath
 echo $newfilepath
 dirpath=$newfilepath%/*
 echo $dirpath
 mkdir -p $dirpath
 git cat-file -p $newid > $newfilepath
 fi
 if [ "$oldid"x != "0000000"x ]; then 
 oldfilepath=$oldpath$filepath 
 echo $oldfilepath
 dirpath=$oldfilepath%/*
 echo $dirpath 
 mkdir -p $dirpath
 git cat-file -p $oldid > $oldfilepath
 fi 
done 
You will found the new directory named patch in current working directory after doing this.
add a comment |Â
up vote
1
down vote
accepted
Thanks all, I have found the correct way, here it is.
#!/bin/bash
from_id=$1
to_id=$2
#echo $from_id
#echo $to_id
diffpath='patch/diff.log'
newpath='patch/new/'
oldpath='patch/old/'
rm -rf patch
mkdir -p $newpath
mkdir -p $oldpath
git diff $from_id $to_id --raw > $diffpath
cat $diffpath | while read line
do 
 #echo =====================================
 #echo $line
 OLD_IFS="$IFS"
 IFS=" "
 arr=($line)
 IFS="$OLD_IFS" 
 #echo $arr[4]
 filepath=$arr[4]##* 
 #echo $filepath
 newid=$arr[2]%%...
 #echo $newid
 oldid=$arr[3]%%...
 #echo $oldid 
 if [ "$newid"x != "0000000"x ]; then 
 newfilepath=$newpath$filepath
 echo $newfilepath
 dirpath=$newfilepath%/*
 echo $dirpath
 mkdir -p $dirpath
 git cat-file -p $newid > $newfilepath
 fi
 if [ "$oldid"x != "0000000"x ]; then 
 oldfilepath=$oldpath$filepath 
 echo $oldfilepath
 dirpath=$oldfilepath%/*
 echo $dirpath 
 mkdir -p $dirpath
 git cat-file -p $oldid > $oldfilepath
 fi 
done 
You will found the new directory named patch in current working directory after doing this.
add a comment |Â
up vote
1
down vote
accepted
up vote
1
down vote
accepted
Thanks all, I have found the correct way, here it is.
#!/bin/bash
from_id=$1
to_id=$2
#echo $from_id
#echo $to_id
diffpath='patch/diff.log'
newpath='patch/new/'
oldpath='patch/old/'
rm -rf patch
mkdir -p $newpath
mkdir -p $oldpath
git diff $from_id $to_id --raw > $diffpath
cat $diffpath | while read line
do 
 #echo =====================================
 #echo $line
 OLD_IFS="$IFS"
 IFS=" "
 arr=($line)
 IFS="$OLD_IFS" 
 #echo $arr[4]
 filepath=$arr[4]##* 
 #echo $filepath
 newid=$arr[2]%%...
 #echo $newid
 oldid=$arr[3]%%...
 #echo $oldid 
 if [ "$newid"x != "0000000"x ]; then 
 newfilepath=$newpath$filepath
 echo $newfilepath
 dirpath=$newfilepath%/*
 echo $dirpath
 mkdir -p $dirpath
 git cat-file -p $newid > $newfilepath
 fi
 if [ "$oldid"x != "0000000"x ]; then 
 oldfilepath=$oldpath$filepath 
 echo $oldfilepath
 dirpath=$oldfilepath%/*
 echo $dirpath 
 mkdir -p $dirpath
 git cat-file -p $oldid > $oldfilepath
 fi 
done 
You will found the new directory named patch in current working directory after doing this.
Thanks all, I have found the correct way, here it is.
#!/bin/bash
from_id=$1
to_id=$2
#echo $from_id
#echo $to_id
diffpath='patch/diff.log'
newpath='patch/new/'
oldpath='patch/old/'
rm -rf patch
mkdir -p $newpath
mkdir -p $oldpath
git diff $from_id $to_id --raw > $diffpath
cat $diffpath | while read line
do 
 #echo =====================================
 #echo $line
 OLD_IFS="$IFS"
 IFS=" "
 arr=($line)
 IFS="$OLD_IFS" 
 #echo $arr[4]
 filepath=$arr[4]##* 
 #echo $filepath
 newid=$arr[2]%%...
 #echo $newid
 oldid=$arr[3]%%...
 #echo $oldid 
 if [ "$newid"x != "0000000"x ]; then 
 newfilepath=$newpath$filepath
 echo $newfilepath
 dirpath=$newfilepath%/*
 echo $dirpath
 mkdir -p $dirpath
 git cat-file -p $newid > $newfilepath
 fi
 if [ "$oldid"x != "0000000"x ]; then 
 oldfilepath=$oldpath$filepath 
 echo $oldfilepath
 dirpath=$oldfilepath%/*
 echo $dirpath 
 mkdir -p $dirpath
 git cat-file -p $oldid > $oldfilepath
 fi 
done 
You will found the new directory named patch in current working directory after doing this.
edited Feb 3 at 12:29


cas
37.7k44393
37.7k44393
answered Feb 2 at 7:05
Huang
184
184
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f420855%2fhow-to-get-the-modified-filesbefore-and-after-from-git-version-server%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
If you want to compare what's different,
git showalready shows the differences. Why do you need the files?â muru
Jan 31 at 4:02
stackoverflow.com/questions/610208/â¦
â cas
Jan 31 at 4:10
@ muru I need to get the midified files(before & after) then compare them, and merge them to another code branch, so I need the modified(before & after) files.
â Huang
Jan 31 at 4:33