I still have yet to try more about Git, but for now I'll show how Git can be used as a tool that can backtrack any progress when working on some local files.
Here's how I played around Git:
I created a parent directory called testplay which contains a directory for the nled package.
All the commands that follow are done inside the testplay directory.
To let Git take revision control of the directory, I typed:
#git init
"Initialized empty Git repository in /home/user/testplay/.git/"
So far Git has no idea about the files or "lines" that it will track. In order for Git to have a snapshot of the directory, 2 commands are needed:
#git add .
#git commit
This enables Git to store the snapshot permanently in the repository. Every commit creates a version (When commit is run, Git automatically takes the user to Vi editor for a commit message).
Alternatively, using
git commit -a
does the same purpose as git add
and git commit
.Branches
The snapshot/version I created was made under a "branch" named "master" by default. Any commits will update this branch. Git can have multiple branches. Branches are names that points to a particular commit. Given are the commands used to best explain what branches are and what they do.Display the branches in the repository
#git branch
* master (where the "*" tells the user that the master branch is active.)
Create another branch from the master branch
#git branch extend1
Git now has 2 branches. I can now create 2 versions of my project based on these branches. A commit or change in one branch wouldn't affect the other unless merged.
To make a desired branch active (In my case 'extend1'):
#git checkout extend1
"Switched to branch 'extend1'"
I created a random file inside the nled/ directory and ran the
git add
and git commit
. If I go back to my "master" branch, the file I created wouldn't be visible; this approach is very useful for debugging and testing out program compilations. :)Useful Links
Official Git pagegittutorial page
gitmagic
0 comments:
Post a Comment