There are a few things that are important to know while getting introduced to Git.
- Git is a way to track changes in a project. It can be done by an individual or a group of individuals.
- It essentially takes a snapshot of a project, the time it was changed and you can add a handy title as well. From there it allows all of those snapshots to be accessed for editing or time travel (in your code)!
- These allow for a much easier and more effective experience making new, and editing code that is preexisting.
There are quite a few steps to use Git, but once you get a hang of them it's not so scary.
-
- Step one is to make a directory and a file inside that directory. This can be done in terminal using the
mkdir
command followed bytouch
.
- Step one is to make a directory and a file inside that directory. This can be done in terminal using the
-
- From here, you have to run
git init
to initialize the program and start the trackment process.
- From here, you have to run
-
- Once git has begun, a project can be added to the staging area where any small changes can be addressed. The command used to move a file from untracked to the staging area is
git add
followed by the file name (ex. git_practice.txt).
- Once git has begun, a project can be added to the staging area where any small changes can be addressed. The command used to move a file from untracked to the staging area is
-
- At this point, you're ready for the projects first commit. Using
git commit -m
(including a brief denotation of the changes made). This is the first snapshot!
- At this point, you're ready for the projects first commit. Using
-
- After this point changes can be repeatedly made, staged and committed. When you're ready to push these changes to GitHub, the
git push
command will add those changes to the repository there.
- After this point changes can be repeatedly made, staged and committed. When you're ready to push these changes to GitHub, the
sample_admin~$ mkdir git_beginner
sample_admin~$ cd git_beginner
sample_admin~/git_beginner$ touch experimenting_git.txt
sample_admin~/git_beginner$ git init
Initialized empty Git repository in /Users/sample_admin/git_beginner/.git/
sample_admin~/git_beginner$ sublime .
*added some text to experimenting_git.txt*
sample_admin~/git_beginner$ git add experimenting_git.txt
sample_admin~/git_beginner$ git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: experimenting_git.txt
sample_admin~/git_beginner$ git push
fatal: No configured push destination.
Either specify the URL from the command-line or configure a remote repository using
git remote add <name> <url>
and then push using the remote name
git push <name>
This last section requires a place to push the file to. Due to the fact this is a sample and there is no repo on GitHub, I recieved this message.