Introduction to git

Events happening in the community are now at Drupal community events on www.drupal.org.
bhosmer's picture

For those of you that missed our recent meetup with David Rogers where he gave a great introduction to git, Randall Schwartz has posted his two-hour long talk that he recently gave: http://vimeo.com/35778382

Comments

Very Timely!

MetsArt's picture

Git and me... we're still trying to get along. :-)

Thanks Ben!

  • Mets

This will make it easy!

sshakir's picture

Check out: http://gitimmersion.com

This may be much easier to digest. Just follow the steps.

If you have any points that

bhosmer's picture

If you have any points that you are getting stuck with, just ask.

Thanks! I have the basics

MetsArt's picture

Thanks! I have the basics down but it gets all mixed up because I committed the wrong files. (Namely, settings.php) I have cloning down, status, add and commit... but I don't fully know how to use the editor (or even which one it is) and I can't find where anyone tells you what specific files do and don't need to be committed. For instance, at one point Git suggested I use "git add ." and I ended up transferring everything! Heh!

Backtracking after a mistake like that is even worse.

I've found some great instructions online (including GitImmersion, thanks!) but I'm working on making some git instructions of my own in order to learn it all better.

  • Mets

Are you using Drush?

sshakir's picture

Are you using Drush as well? I am asking because it made my life a lot easier when I need to keep our sites in sync. He touches on settings.php when he goes in rsync. Check out Mike's video from Drupalcamp Atlanta if you haven't already: http://vimeo.com/30476215

Be careful with git add . Try

bhosmer's picture

Be careful with git add .

Try git rm /sites/default/settings.php to remove this file from being tracked. Keep in mind, git just tracks the changes you make to files, it doesn't actually change the files.

No Drush yet...

MetsArt's picture

Sshakir: I have not tried Drush yet. I have the program but have not had the opportunity to work with it yet. Thanks for the link!

Ben, I'm not using 'git add .' anymore! Heh! Learned that lesson. Backtracking is not a fun way to learn but it's pretty effective. I realize that it's only the changes that are being sent but Git doesn't care if you should send them or not. Git status simply lists ALL the changes and I didn't know which ones were correct to send. I was working on a D6 to D7 migration so pretty much everything had changed. See what I mean? I didn't know that normally, I would only be adding changes to the modules or themes files.

I'm getting there. Thanks for the help!

  • Mets

No problem. It sounds like

bhosmer's picture

No problem. It sounds like you are making some quick progress now.

Often, we will add /sites/default/settings.php and sites/default/files/* to a .gitignore file, that way you can't accidentally add them and push them.

Here is a sample .gitignore:

# Ignore configuration files that may contain sensitive information.
sites//settings.php

# Ignore paths that contain user-generated content.
sites//files
sites/
/private
tmp

You can add this as a global .gitignore or you can simply add a .gitignore file to your root directory. Git will ignore any files that are listed.

I'm liking .gitignore a lot...

MetsArt's picture

I fully understand the .gitignore file but at first, I didn't know what files should go into it. Ya know? I'm learning though. :-)

(git status is a fave too. )

  • Mets

Stuck

SawyerMerchant's picture

Hello:
How do I save and exit while in the editor within terminal?

To explain further, in the Git Immersion tutorial I am stuck on the 8th Lab: using the editor to include a message with a commit rather than using -m.

I have executed $ Git commit and the editor within terminal reads as follows:

Please enter the commit message for your changes. Lines starting

with '#' will be ignored, and an empty message aborts the commit.

On branch master

Changes to be committed:

(use "git reset HEAD ..." to unstage)

#

modified: hello.rb

#

The tutorial says to type “Using ARGV”, then to save and exit the editor. I am not sure what commands to use to save or exit. Please help. Thank you.

I did not change the editor variable first (not sure if this is a problem

@SawyerMerchant save and

tommyent's picture

@SawyerMerchant save and exit would depend on what editor you are using. If it's a commit message that you are trying to commit you can specify the editor with something like
git config --global core.editor your_editor
You can use something outside of terminal like Textmate as far as I know. As for the file you are talking about adding an argument to you may want to just edit these in your preferred editor if you have a default set you can just do
open hello.rb
but if not and you want to pick up something else to learn
http://staff.washington.edu/rells/R110/

Using vi you enter text mode with i then esc to get out then :wq to write and quit.
Or you can take a look at nano
http://www.nano-editor.org/
With nano I think you can just do control x then y

It is quite possible that

bhosmer's picture

It is quite possible that your default text-editor is vi. You would first hit esc then type :wq and enter. Or you can use ctrl c to cancel a command.

Thank you

SawyerMerchant's picture

That did the trick

Which one? ctrl c or :wq ?

bhosmer's picture

Which one? ctrl c or :wq ?

:wq

SawyerMerchant's picture

:wq

I am guessing you are most

bhosmer's picture

I am guessing you are most likely using a mac. The default text editor is vi (pronounced vee-eye).

You can avoid this by using "git commit -m "Your commit message"

Or you can set a different text-editor to be your default.

Florida

Group organizers

Group categories

Florida Topics

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: