We must first learn how to initialize a Git repository before learning any Git subcommands.
Let's create one a project called fun-project, and move into it by typing the following:
$ mkdir fun-project $ cd fun-project
Once we're in our directory, we can initialize Git with the
$ git init
Initialized empty Git repository in /Users/johndoe/test/fun-project/.git/
Great! You just created your first Git repository! By running the
init subcommand, you have created a hidden folder in the current directory called .git. This folder, along with any of its contents, should not be edited or removed.
If you're more interested in someone else's work and want to look at their source code, or just want to download a cool application off of Github, we can use the
Here, we're obtaining source code from Heng Li, a renowned bioinformaticist who has contributed heavily on Next Generation Sequence data analysis. We'll pull in
wgsim, an artificial reads generator. Although this project has been retired and is no longer maintained, it's good enough for demonstration purposes. Simply copy the URL on the side (click the clipboard button) and paste it after the
$ git clone https://github.com/lh3/wgsim
Cloning into 'wgsim'... remote: Counting objects: 43, done. remote: Total 43 (delta 0), reused 0 (delta 0), pack-reused 43 Unpacking objects: 100% (43/43), done. Checking connectivity... done.
This command will download all the project contents into your local hard drive. You may now go ahead and tweak the files or use the program without affecting the main repository online.
One of the most frequent and informative subcommands you'll use is
status. With this, you can check which files are in the staging area (ready to be placed in the next commit), and what is and is not being tracked.
$ git status
On branch master Initial commit nothing to commit (create/copy files and use "git add" to track)
We can see that we're on the branch master, which is the default git branch. We also see that we have nothing to commit (yet). Considering we have not created any files yet, this is true and expected. Let's now create some files and add it to our repository!
Introduction to Algorithms uniquely combines rigor and comprehensiveness. The book covers a broad range of algorithms in depth, yet makes their design and analysis accessible to all levels of readers. The algorithms are described in English and in a pseudocode designed to be readable by anyone who has done a little programming.$ Check price
In this completely revised second edition of the perennial best seller How Linux Works, author Brian Ward makes the concepts behind Linux internals accessible to anyone curious about the inner workings of the operating system. Inside, you'll find the kind of knowledge that normally comes from years of experience doing things the hard way.$ Check price