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!
Get a comprehensive, in-depth introduction to the core Python language with this hands-on book. Based on author Mark Lutz's popular training course, this updated fifth edition will help you quickly write efficient, high-quality code with Python. It's an ideal way to begin, whether you're new to programming or a professional developer versed in other languages.$ Check price
Agile has revolutionized the way teams approach software development, but with dozens of agile methodologies to choose from, the decision to "go agile" can be tricky. This practical book helps you sort it out, first by grounding you in agile's underlying principles, then by describing four specific and well-used agile methods: Scrum, extreme programming (XP).$ Check price