If you're starting from an existing project in Git, you need to go to that project's directory in the terminal. Go ahead and navigate into that directory with 'cd /name of directory'. Then type the following:
This creates a subdirectory named '.git' that contains all the needed files for a Git repo. So far you've installed Git, and now you have to begin tracking your project. Go ahead and type the following:
Now it's time to track changes to your project. As you edit your files, Git sees them as modified since your last commit. Go ahead and make a change to a file, or add a file in the project, and type this:
At this point, you should see that Git has noticed a change in your directory. Untracked changes will remain that way until you commit them. When you 'git commit' them, you are staging changes, then tracking them. These two states are the key concepts that manage your style of development. A common life cycle that repeats itself often.
The best practice is to 'git commit' all changes with a clear description, annotating them for future observation. So when you or others revisit a change you've committed, you understand exactly what you've done.
If you haven't made any changes, you'll see the following:
This means nothing has changed and there are no new files in your working directory. Now go ahead and add a change or file to your directory and type 'git status'.
You should see the name of the file you've added. Go ahead and stage the file: git commit -m or git add . then add your description of the change in quotes: "I added a file to test git." Congratulations, you're now tracking files. For more info: go to Pro Gita great resource for all about Git.
When you create a project on Github, you will need to clone this repo to your local repository. See the next Cheatsheet: How to Clone a Git Repository for info on how do this, after you've gone through all the following steps.
Github is a place to put your project, you'll need a Github account to do this. Once you have an account set up, you'll then create a repository for each project.
Anyhow, first create a new repository in your Github account. It's the first graphic just right of your name in the top upper-right of your browser window.
Name your repository with a simple, easy to understand name. It will save you hours of guessing.
Describing your project is optional but when working with others it's quite useful.
Simply check a radio button to activate the settings. Making projects Public means everyone can see them, while making projects Private will require an invitation to others to see and join your project - useful when you're working with clients.
If you check the button "Initialize this repository with a README", this will allow you to clone the repo from the command line, or from the repository's front page immediately.
From the repo's front page, choose the "Clone in Mac" button and it will launch the Github App, where you'll be able to manage all repos through the Gitbhub GUI. If you don't have the Github app, you'll be prompted to download it.
Then click the button and you're all done.
You can start at the command line and create your local repository first.
Create your directory, install git and initialize your repo with a README file, where you describe your project, add documentation and provide contact information. All extremely useful from the get go.
Okay so here's what's happening: mkdir (make the directory)~(the tilde is your home directory) / Project-Folder, then cd / Project-Name, the git init stuff, and finally touch; the utility that creates the README file.
Now open the new README file from a text editor, and add a greeting "Yay Railsbridge!" Save it and close the file. Now commit your README file:
Now we have to push the commit, remember it's only local. Go to the next step.
Everything you've done so far has been local, which means nothing is on Github yet. Have your username handy, which is basicly the name of your account for this next step.
To connect your local repo to your GitHub account, you'll need to set up a remote for your repo and then push your commits to it:
Go back to your repository on Github and you'll see your README file has been added. From this point forward, to push commits to your Gibhub repo, follow this recipe (only when working solo):