My git process

I’m starting to use git a lot more now I am commiting code to github. Just for my reference I do the following for each commit

git init

required only if you are creating a git repository from scratch.

git status

This displays the files deleted and modified and not tracked.

git add .

add . adds any new (untracked) files to the git repository so now they are tracked. Make sure you include the period as this tells it to go through the whole directory and subdirectories.

git commit -a

This initiates a commit. git asks for a commit message, which you type in and then do Ctrl+x to save . It then asks you to save the buffer, you enter “y” to continue, then hit enter to confirm the file to save the git edits to. The command updates the local repository with all the physical changes on the disk so deletes files that aren’t there, adds new files, and updates files that have changed.

git push origin master

this updates the remote repository – in this case my github repostitory. You may have to set this up initially in github by creating a new repo and using the supplied url to set it up locally:

git remote add origin https://github.com/lalexgraham/SenchaLocalStorage.git

If I make a mistake on the original git repository (e.g. do not include all the directories I choose to ignore in .gitignore) I just delete the.git directory and start over. This can’t be done I guess if you have a remote repository set up.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s