[Sugar-devel] git problems (reprise)

James Cameron quozl at laptop.org
Tue Dec 28 22:29:56 EST 2010


On Tue, Dec 28, 2010 at 03:47:27PM -0500, Art Hunkins wrote:
> Thanks for your wonderful, clear and understandable instructions.
> They work wonderfully and all my problems are gone.

Oh, good.  I've struggled with git, especially in any situation where
repositories diverge, so I'm glad to be able to explain it.

> BTW, your procedure is *much* more user-friendly (and simpler) than
> any of the git material on the wiki. It would really be helpful to
> have your easy step-by-step available online: perhaps one procedure
> for initial commit, and one for followups (like for my case). Of all
> the challenges I've faced with Linux/Sugar, perhaps gitorious has
> been the greatest and most frustrating.

I think part of this is what Walter said in another thread; concepts
such as git, gitorious, ssh, and diff become convolved, or conflated.
But I would be interested in improving what documentation we have.

> Please advise me on one point: once the local repo is established
> (filemix.git), what's the simplest way to copy all my (revised)
> activity files (including subdirectory) to filemix.git?

Simplest is hard to define, since I don't know what your exact skills
are, but here are some ways that I think are simple; choose one of these
ways:

a.  figure out from file modification dates which files you changed,
then copy them ...

	cd ~/Activities/FileMix.activity
	ls -actl | more

	cp filemix.py FileMixReadMe.txt ../filemix.git/
	cp activity/activity.info ../filemix.git/activity/

        cd ~/Activities/filemix.git
        git add filemix.py FileMixReadMe.txt activity/activity.info
        git commit -m 'comment'
        git push

('ls -actl' lists most recently changed files first, from which you
choose which files to copy).

b.  figure out from a mechanical comparison which files you have
changed, then copy them ...

	cd ~/Activities
	diff --recursive --brief filemix.git FileMix.activity | more

	cd ~/Activities/FileMix.activity
	cp filemix.py FileMixReadMe.txt ../filemix.git/
	cp activity/activity.info ../filemix.git/activity/

	cd ~/Activities/filemix.git
	git add filemix.py FileMixReadMe.txt activity/activity.info
	git commit -m 'comment'
	git push

(the 'diff' command compares the files in the two directories and lists
those that are changed, from which you choose the files to copy).

> When preparing a new push, I've often forgotten just which files I've
> modified, and don't wish to omit any (and so would use git add . for
> the following step).

Instead of copying only the files you know you have changed, you could
copy all your files in the activity directory, then use 'git status' to
find out what git notices as changed, and 'git add' on each.  git will
not commit anything for a file that is unchanged since it last saw it.

	cd ~/Activities/FileMix.activity
	cp -r * ../filemix.git/

	cd ~/Activities/filemix.git
	git status
	git add ...
	git commit -m 'comment'
	git push

(where ... represents the names of the files you have chosen to include
in the commit, based on the output of 'git status' and your memory of
what you changed).

> Let's say that the source files were in FileMix.activity and that both
> FileMix.activity and filemix.git were in the Activities folder.

My response above is in agreement with what you suggest.

However ...

Another way of laying out your directories is to swap those two names,
and run the activity from the git clone.  This way you don't need to
copy files around at all, and can focus on editing the files and using
git to track the changes or publish them.

Initial setup:

	cd ~/Activities
	mv filemix.git FileMix.activity.new
	mv FileMix.activity FileMix.activity.old
	mv FileMix.activity.new FileMix.activity

(this swaps the contents of the two directories ... you can tell which
one is the git repository because it has a file .git ... and after this
setup you no longer use the .old directory)

You might need to restart Sugar at this point, I'm not sure.  I always
did.

Then, your development cycle is shortened ...

	cd ~/Activities/FileMix.activity
	... [edit the files] ... [test the activity] ...

	git status
	git add ...
	git commit -m 'comment'
	git push

-- 
James Cameron
http://quozl.linux.org.au/


More information about the Sugar-devel mailing list