ninetydegrees: Art & Text: heart with aroace colors, "you are loved" (Default)
ninetydegrees (90d)☕ ([personal profile] ninetydegrees) wrote in [site community profile] dw_dev_training2012-08-28 11:00 am
Entry tags:

Git: more newbie questions

1) If you're working on bug A on branch A then want to work on completely unrelated bug B on branch B, do you need to stash you changes on A checkout develop then create branch B?

Answer: yes, but see comments about using git commit and git commit --amend in your workflow.

2) When can you use git diff? Before add only? Because otherwise it gives me nothing and I have to use git status -v.

Answer: possibly with git diff --cached or git diff HEAD^ HEAD (untested)

3) Oh I feel so stupid for asking this but how do you get out of git diff or git log on PuTTY? Ctrl+C and Ctrl+X don't work.

Answer: the magic key is 'q' and this is related to PAGER and not PuTTY

4) If you're working on bug A on branch A and have reached a point where you want to do some more work but be easily able to revert to where you were before, what is the best route? Several commits? Creating a subbranch A1 (is that possible?)? Is that where merge is useful? I'm having the hardest time understanding how merge can be used concretely.

Answer: several commits is indeed the best route; the concept of 'subbranches' isn't valid.

5) In git config, is there a way to reset the value of core.editor to whatever is the default on your computer (without naming the editor)?

Answer: yes, with git config --global --unset core.editor
dereckson: (Default)

[personal profile] dereckson 2012-08-28 12:32 pm (UTC)(link)
(1) This is right. Or you can commit your work on bug A and amend the commit later. My current workflow is something like:

git checkout -b bug/a
#fixing bug A
#oh, I now have to work on B
git commit
git checkout -b bug/b
#fixing bug B
git commit
git checkout bug/a
#fixing bug A (end)
git commit --amend


commit --amend should only use for local changeset, and not on already pushed somewhere else changesets to maintain consistency.

Side note: if you clutter your branch with unmerged changes, for example doing a git pull in A to rebase against master for example, you won't be able to leave A easily. git merge --abort will help.

(2) You can try stuff like git diff --cached or git diff HEAD^ HEAD
(HEAD^ is HEAD minus a version)

(3) This isn't a PuTTY-related question, but a PAGER one.

Some commands are sent to more (or less), softwares to allow to browse up and down contents.

To quit, the key to use is 'q'.

(4) I would do several commits, this produce a clean interface.

You will even be able to merge all these commits into one with git merge when you leave the branch.

By the way, subbranch isn't a valid concept: branches aren't path of codes, but more bookmarks indicating the changesets to work with.

You'll get more information on the concept of branches in the following document:
http://eagain.net/articles/git-for-computer-scientists/

(5) I think in this case the default value would be your EDITOR environment variable (echo $EDITOR).

So your question become "how to remove core.editor setting from git config?".

I'm not sure for this one, but I would try git config --unset core.editor.
dereckson: (Default)

git config

[personal profile] dereckson 2012-08-28 01:10 pm (UTC)(link)
Mais de rien, c'est un plaisir de pouvoir t'aider si ces informations te sont utiles.

A scope (--global/--system/--local) should probably be added.

To get all the settings:
* git config --global -l
(will read ~/.gitconfig)
* git config --system -l
(system-wide /etc file, if it exists ; in FreeBSD this is /usr/local/etc/gitconfig)
* git config --local -l
(settings for the current repository)

The following test worked fine, with --global:

(doing a change)
/home/dereckson/dev/mediawiki/www ] git commit
(it opens a commit message buffer in nano, following my EDITOR variable)
/home/dereckson/dev/mediawiki/www ] git config --global core.editor vi
/home/dereckson/dev/mediawiki/www ] git commit
(it opens this time the commit message buffer in vi)
/home/dereckson/dev/mediawiki/www ] git config --global --unset core.editor
/home/dereckson/dev/mediawiki/www ] git commit
(back to nano)
yvi: Kaylee half-smiling, looking very pretty (Default)

[personal profile] yvi 2012-08-28 04:52 pm (UTC)(link)
Thank you for asking these questions, by the way! I won't have time to do any coding before the weekend, but I will almost certainly run into scenario 1 and 4 at some point :)
momijizukamori: Green icon with white text - 'I do believe in phosphorylation! I do!' with a string of DNA basepairs on the bottom (Default)

[personal profile] momijizukamori 2012-08-28 11:49 pm (UTC)(link)
I'm glad you ask these things so I don't have to *g*
momijizukamori: Grey tabby cat with paws on keyboard and mouse. The text reads 'code cat is on the job', lolcats-style (CODE CAT)

[personal profile] momijizukamori 2012-08-29 08:27 pm (UTC)(link)
I was wondering similar things, and also clutching mercurial queues close because aaaaah I know that system.
denise: Image: Me, facing away from camera, on top of the Castel Sant'Angelo in Rome (Default)

[staff profile] denise 2012-08-29 08:36 pm (UTC)(link)
Yeah, I was totally trepidatious about OH NO HUGE NEW THING TO LEARN. then I tried it. NEVER GOING BACK, THANK YOU
foxfirefey: A picture of a hand where inked stick figures hug across fingers with a heart above them. (hearts)

[personal profile] foxfirefey 2012-08-29 08:45 pm (UTC)(link)
Hearing you say that you are now having a good experience with this transition relieves me to no end.
momijizukamori: Green icon with white text - 'I do believe in phosphorylation! I do!' with a string of DNA basepairs on the bottom (Default)

[personal profile] momijizukamori 2012-08-29 08:59 pm (UTC)(link)
Yeah, Dre was mentioning the images thing to me at one point - there was a way to enable git-style patches like that in MQ but I never enababled it.

Guess I'll take the plunge and move my Hack over today *g*