Wednesday, February 6, 2013

Using Git and GitHub on Linux

Description: This guide will go over the basics of git and the use of GitHub to version your projects.

Git Installation and Setup
The instructions in this guide are taken from here.
To install git on Linux, execute the following commands:
su root
yum install git

To set the default name and email globally for git to use when you commit:
git config --global user.name "username"
git config --global user.email "username@example.com"

To set the default name and email for a specific repository:
cd your_repository
git config user.name "yourUserName"
git config user.email "youEmailUsedForGit@example.com"

Generating SSH Key
You can find the original guide here.
Here is the troubleshooting guide.

Creating and Setting up a Repository
You can find the original guide here.
On the GitHub home page, click the "Create repository" button.

To setup a git repository you've created, follow the given steps below:
1. Go into the directory of an existing project or create a new directory for your project and go into it.
2. Initialize an empty git repository inside your project directory by executing "git init".
3. Create a README file inside your project folder and write a description in that file.
4. Add your files. The "git add" command puts your files into staging.
5. Commit your files.  Committing your files applies changes in your local repository.
6. Create a remote name "origin" pointing at your GitHub repo.
7. If you are using ssh, modify the url variable in the ".git" file or execute a command to set it.
8. Push your commits to your GitHub account.
cd /home/oracle/NetBeansProjects/[PROJECTNAME]
git init
touch README
git add *
git commit -m 'first commit comment';
git remote add origin https://github.com/[USERNAME]/[PROJECTNAME].git
git remote set-url origin ssh://git@github.com/[USERNAME]/[PROJECTNAME].git
git push --force origin master

No comments:

Post a Comment