[kwlug-disc] Advanced(?) Git usage question
John Johnson
jvj at golden.net
Thu Apr 17 00:00:12 EDT 2014
Earlier I asked:
/What happens if I have modified a file in one of the branches?
Say it is a file accessible through FF with
/localhost/projectName/indexTest.php
/
I think I have an answer.
$ git checkout rewind_2f7c343 (switch to branch)
test in FF: /localhost/projectName/indexTest.php
behaviour is w (this is a problem)
modify file indexTest.php
w/o commit
test in FF: /localhost/projectName/indexTest.php
behaviour is x (problem of w is gone)
$ git checkout rewind_f9a4506 (switch to branch)
test in FF: /localhost/projectName/indexTest.php
behaviour is x (was y + w before mods)
$ git checkout rewind_ad95724 (switch to branch)
test in FF: /localhost/projectName/indexTest.php
behaviour is x (was z + w before mods)
behaviour x is from the uncommited (staged?) file modified under
rewind_2f7c343
$ git checkout rewind_2f7c343 (switch to branch)
$ git commit -a
to commit changes to indexTest.php
test in FF: /localhost/projectName/indexTest.php
behaviour is x (problem of w is gone)
$ git checkout rewind_f9a4506 (switch to branch)
test in FF: /localhost/projectName/indexTest.php
behaviour is y + w (problem w is present)
$ git checkout rewind_ad95724 (switch to branch)
test in FF: /localhost/projectName/indexTest.php
behaviour is z + w (problem w is present)
Now, the trick I have at hand is to merge the changes in indexTest.php
made in rewind_2f7c343 with the other branches.
And do this so that only the problem with behaviour w is addressed, i.e.
without affecting the other behaviours present in the other branches.
Learning by doing.
Hopefully, in the right direction.
Thanks
John Johnson
On 2014-04-16 22:16, John Johnson wrote:
> The question below (re: git 'pull' of a specific file [w/o overwriting
> current]) remains at least for me, open.
>
> But I now, have one or more advanced (I think) questions.
>
> My environment: Windows XP on one PC. Linux Ubuntu on another. The
> Linux PC is the intended the deployment target.
> Development is on the Windows XP PC under XAMPP. Git for Windows is
> installed on the Windows PC. (Not yet on the Linux PC.)
>
> It had to happen. Somewhere in the past couple of days, and after a
> few Git commits things went sideways.
> And I find myself having to do, what I call a 'rewind', i.e. a git
> branch to an earlier commit (maybe more than one branch).
>
> A week or two ago, the Master was branched to newBranch, which became
> the main development path. The Master is now dated and useless.
> (newBranch? OK OK so I am not very creative with the naming!)
>
> And now, while under the branch newBranch, I have executed one or more
> commands like:
> $ git checkout -b rewind_f9a4506 f9a4506
> Where f9a4506 is the git assigned commit ID.
> (rewind_f9a4506? Again, I am not being creative with the branch
> naming, but at least this one carries more information than 'newBranch'.)
>
> When the branch command is executed I see the message:
> Switched to a new branch 'rewind_f9a4506'
>
> This is all well and good in the Git bash window.
>
> And I can, for various reasons, navigate between the branches with the
> commands:
> $ git checkout newBranch
> $ git checkout rewind_f9a4506
> $ git checkout rewind_ad95724
> (Note: I am exploring and have done no mods or commits in these branches.)
>
> It appears that when XAMPP and using FF, /localhost/projectName/ into
> the browsers address bar brings up the index.php for the branch
> currently active in the Git bash window.
>
> Is this a correct assumption?
> I can understand the 'view' of the files as given through the Git bash
> window. But I am not clear as to how Windows apps, e.g. a text editor,
> and XAMPP find the files associated with the branch currently active
> in he Git bash window.
>
> What happens if I have modified a file in one of the branches?
> Say it is a file accessible through FF with
> /localhost/projectName/indexTest.php
>
> I have not yet got to the stage where I will update the Master or
> newBranch with one of the branches.
> Or create and update a remote repo, i.e. on the Linux PC.
>
> As said earlier: tips / comments / guidelines / advice / etc. from
> those who have gone before me are welcome.
>
> Thanks
> John Johnson
>
> On 2014-04-16 11:33, John Johnson wrote:
>> This is definitely, not an an "advanced" question.
>> But it is one for which I could not an answer on the Google or in Git
>> tuts.
>>
>> Using Git, can one, without creating a branch, pull a file from an
>> earlier commit?
>> And (asking a lot) store the pulled file in a place other than the
>> current working directory?
>>
>> Unless I need to do some more reading, git commands, revert pull and
>> checkout all seem to operate on the repo as a whole and not on
>> individual files.
>>
>> Tips / comments / guidelines / advice / etc. from those who have gone
>> before me are welcome.
>>
>> Thanks
>> JohnJ
>>
>>
>>
>> On 2014-04-15 21:44, Chris Frey wrote:
>>> On Tue, Apr 15, 2014 at 08:47:41PM -0400, John Johnson wrote:
>>>
>>>> A tip on Git that I read somewhere was to develop a consistent style
>>>> in the git commit messages, e.g. git -am [message text], so as to
>>>> make subsequent searches easier. For example, if one was using an
>>>> issue tracking system with issues SCR 1024 SCR 2031 SCR 112 being
>>>> active and the commit was to combine repairs that addressed these
>>>> issues, the commit message could be: git commit -am "issues: SCR
>>>> 1024 SCR 2031 SCR 112" or similar.
>>>>
>>> That "git commit -am" worries me. :-) My usual process is:
>>>
>>> git add -p
>>> git commit # with editor
>>>
>>> This allows more detailed commit messages than just a single line.
>>> And the git-add with '-p' makes sure you only commit the changes you
>>> intend. You can also break your current workspace into multiple
>>> commits, making them small and logical.
>>>
>>> Also, in git, the first line is special, as you probably know.
>>> But there exists a --grep option in commands such as git-log, for
>>> searching commit messages. For example, if your commit message said:
>>>
>>> driver: fixed off-by-one error in buffer init
>>>
>>> Changed code to use sizeof() instead of hard coded value.
>>>
>>> Fixes SCR 1024, SCR 2031, SCR 112
>>>
>>> Now, if you do:
>>>
>>> git shortlog
>>>
>>> you get a nice brief description of your changes, yet you still have
>>> your bug tracking IDs in the commits, so that this is possible:
>>>
>>> git log --grep="SCR 2031"
>>>
>>> - Chris
>>>
>>>
>>>
>>> _______________________________________________
>>> kwlug-disc mailing list
>>> kwlug-disc at kwlug.org
>>> http://kwlug.org/mailman/listinfo/kwlug-disc_kwlug.org
>>>
>>>
>>> -----
>>>
>>> Checked by AVG -www.avg.com
>>> Version: 2014.0.4355 / Virus Database: 3882/7345 - Release Date: 04/14/14
>>>
>>>
>>>
>>
>>
>> _______________________________________________
>> kwlug-disc mailing list
>> kwlug-disc at kwlug.org
>> http://kwlug.org/mailman/listinfo/kwlug-disc_kwlug.org
>>
>>
>>
>>
>> Checked by AVG - www.avg.com <http://www.avg.com>
>> Version: 2014.0.4355 / Virus Database: 3882/7349 - Release Date: 04/15/14
>>
>
>
> _______________________________________________
> kwlug-disc mailing list
> kwlug-disc at kwlug.org
> http://kwlug.org/mailman/listinfo/kwlug-disc_kwlug.org
>
>
>
>
> Checked by AVG - www.avg.com <http://www.avg.com>
> Version: 2014.0.4355 / Virus Database: 3882/7354 - Release Date: 04/16/14
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://kwlug.org/pipermail/kwlug-disc_kwlug.org/attachments/20140417/bbb98f01/attachment.htm>
More information about the kwlug-disc
mailing list