Board index FlightGear Development

Understanding git commit  Topic is solved

FlightGear is opensource, so you can be the developer. In the need for help on anything? We are here to help you.
Forum rules
Core development is discussed on the official FlightGear-Devel development mailing list.

Bugs can be reported in the bug tracker.

Understanding git commit

Postby macnab » Mon Jul 22, 2013 3:59 pm

I currently have 3 files in the folder that are "stored" at the project at git. (Not fgdata.)
I'm running git bash for Windows. 1.81.1.mysys.git.1

To commit, I can use (I presume the -a means all changed)
Code: Select all
git commit -a <comment>

It shows which files have changed, in Technicolor, but trying to type the comment has no effect. Nothing happens, all I have is a square flashing cursor at the top of the window.

With the following (I presume -m means manual mode)
Code: Select all
git commit -m <comment>

I must first use
Code: Select all
git add <file> ..

This could be a pain if I had 700 changed files. :D

Any help is appreciated. :D
macnab
 
Posts: 886
Joined: Tue Aug 02, 2011 7:20 am
Location: Johannesburg, South Africa
Callsign: ZS-ILH
Version: Git
OS: Win7Pro 64bit SP1

Re: Understanding git commit

Postby Hooray » Mon Jul 22, 2013 4:22 pm

Comments are added at the commit-level, not when you are adding files.

Use "git add filename.nas file2.nas file3.nas etc" to add files that are to be committed - you can also use wildcards, like for example: git add *.nas
Use git commit -m "message" to commit added changes using the message you specified.
For files that are already known to git (in the index), you can also use git commit -a -m "message" which tracks all KNOWN files that were changed and commits those using the message that you specified.

In case of doubt, use git help or git help add, git help commit etc
Last edited by Hooray on Mon Jul 22, 2013 4:23 pm, edited 1 time in total.
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11378
Joined: Tue Mar 25, 2008 8:40 am

Re: Understanding git commit

Postby Philosopher » Mon Jul 22, 2013 4:22 pm

The Git commit command accepts two important flags:
  • -a: This commits all changes you have made. When you type in «git status», there are staged and unstaged changes. Without the -a flag, a commit will only commit the staged changes, but with it the unstaged changes will be staged and committed.
  • -m "message": This is just a shortcut to type in a message (instead of using vim or such).

I typically use -a, but sometimes I am working in a parallel fashion and I might only want to commit changes to, say, the debugging macros. I stage those changes and leave the -a flag out of the commit. But if I have just made changes to one thing, I instead use the -a flag since they (usually) are still unstaged. Note that the -a flag, while similar to «git add -A» (-A for all files) but it will not add files that are not tracked by git and instead will only affect changes to files.
Thanks,
Philosopher
(inactive but lurking occasionally...)
Philosopher
 
Posts: 1590
Joined: Sun Aug 12, 2012 6:29 pm
Location: Stuck in my head...
Callsign: AFTI
Version: Git
OS: Mac OS X 10.7.5

Re: Understanding git commit

Postby Hooray » Mon Jul 22, 2013 4:38 pm

windows folks should have a look at one of the GUI frontends for git, such as TortoiseGit - or just use an IDE like Eclipse/NetBeans that has integrated git support - a more lightweight option would be a TextEditor that has git support.
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11378
Joined: Tue Mar 25, 2008 8:40 am

Re: Understanding git commit

Postby macnab » Mon Jul 22, 2013 4:58 pm

windows folks should have a look at one of the GUI frontends for git, such as TortoiseGit

It still doesn't help if I don't know what I am doing!!!

The way I understand it, so far:
I have 2 files bbb.ff and gg.xx which I have committed and pushed.

I add a file aa.ddd, which I have never committed before. So I use
Code: Select all
git add "aa.ddd"


I edit bbb.ff. Now I want to commit all the changes, with a comment. What are my git commands?

EDIT:
Code: Select all
git add "*.*"

seems to stage all changed files. Does it stage unchanged files, so they also (unnecessarily) get committed?
Last edited by macnab on Mon Jul 22, 2013 5:08 pm, edited 1 time in total.
macnab
 
Posts: 886
Joined: Tue Aug 02, 2011 7:20 am
Location: Johannesburg, South Africa
Callsign: ZS-ILH
Version: Git
OS: Win7Pro 64bit SP1

Re: Understanding git commit  

Postby Philosopher » Mon Jul 22, 2013 5:04 pm

Two options:
Code: Select all
git add bbb.ff
git commit -m "Message here"

Or:
Code: Select all
git commit -a -m "Message"


Since you already have the new file added in Git, you can use -a (second example) to pick up the changes to bbb.ff -- or you could manually add it using git add (first example). Also, if you leave out the -m "Message" part you will get an editor like vim that you can type your message into (if you don't know how to use vim: press "i", type out your message, hit escape, and type ":wq" <enter> to commit or ":q!" <enter> to cancel the commit).
Thanks,
Philosopher
(inactive but lurking occasionally...)
Philosopher
 
Posts: 1590
Joined: Sun Aug 12, 2012 6:29 pm
Location: Stuck in my head...
Callsign: AFTI
Version: Git
OS: Mac OS X 10.7.5

Re: Understanding git commit

Postby Gijs » Mon Jul 22, 2013 5:07 pm

Run gitk for a visual representation of the commits. This can help a lot to understand what you're doing/did. And it prevents silly mistakes ;-)
Airports: EHAM, EHLE, KSFO
Aircraft: 747-400
User avatar
Gijs
Moderator
 
Posts: 9385
Joined: Tue Jul 03, 2007 2:55 pm
Location: Amsterdam/Delft, the Netherlands
Callsign: PH-GYS
Version: Git
OS: Windows 10

Re: Understanding git commit

Postby macnab » Mon Jul 22, 2013 5:18 pm

Got it now. Thanks.
macnab
 
Posts: 886
Joined: Tue Aug 02, 2011 7:20 am
Location: Johannesburg, South Africa
Callsign: ZS-ILH
Version: Git
OS: Win7Pro 64bit SP1


Return to Development

Who is online

Users browsing this forum: YandexBot [Bot] and 1 guest