##Initializing a new repo
Link to video
Type in what comes AFTER the $...do not type in the $
BASIC git initialization and repo creation:
$ git init
This command creates an empty git repository - basically a .git directory with subdirectories for objects, refs/heads, refs/tags, and template files. An initial HEAD file that references the HEAD of the master branch is also created.
Now, choose which file to be added - in this case, 'my_file.rb'
$ git add my_file.rb
Using a '.' instead of a file name will add all files and folders within the CURRENT WORKING DIRECTORY
Don't know what you added? Use the following:
$ git status
And you'll see:
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: my_file.rb
Once you have your files added, commit them
$ git commit -m 'message goes here in between quotes (single or double) '
This commits the added files/folders along with the message. Now, you'll want to give it the info on your repo and tell it where your origin master is located:
Step required only if this is a brand new repo, not a clone
$ git remote add origin https://github.com/YOUR_GITHUB_NAME/REPO_NAME.git
You can just copy paste the above line once you create your repo on github.com. This can also be done with an SSH key but we aren't using that today.
The last piece, push your local files up to 'The Clooouuud'
$ git push origin master
And you'll see something along the lines of:
Counting objects: 3, done.
Writing objects: 100% (3/3), 208 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/ysadka/git_tutorial.git
* [new branch] master -> master
Want to see that your origins are set up correctly?
$ git remote -v
Returned (if your github name is ysadka and the repo name is git_tutorial) :
origin https://github.com/ysadka/git_tutorial.git (fetch)
origin https://github.com/ysadka/git_tutorial.git (push)
In
2recursive_steps.md
, after mentioning thatgit add .
adds ALL the files to the commit, it would be helpful to add thatgit reset
will remove that file from the commit (in case the person realizes that not all the files shouldbe in this commit).It might also be worth mentioning that
git rm
also removes the file from the commit, but additionally deletes the file from the project.