Download Git Through Terminal Mac
After you have successfully installed Git on Mac, you’ll need to provide secure communication with your Git repositories by creating and installing SSH keys. Creating SSH keys on Mac To communicate with the remote Git repository in your Beanstalk account from your Mac, you will need to generate an SSH key pair for that computer. You can also type git commit with no additional tags or options. However, when doing this it opens a vim like editor that can be difficult for those not familiar with the vim to use. If you type this command press 'i' to enter insert mode and type the notes for the commit on the first line, press Esc, and then type ':wq' to save, exit, and commit. We suggest using the above command. Jan 09, 2020. Jan 05, 2019. Sep 13, 2020.
by Gowtham Venkatesan
Yes, the title is a clickbait. There is no way you can understand the basics of git technology in just 10 minutes. But you can get pretty close in about 25 minutes. And that is the purpose of this article.
If you want to get started on learning about Git technology, you’ve come to the right place. This is a comprehensive beginner’s guide to Git. There are many clients for Git. The technology is all the same no matter the client. But in this guide we’ll be using GitHub to understand Git.
Let’s get started!
What is Version Control?
Version control is a system that records changes to a file or set of files over time so that you can recall specific versions later. So ideally, we can place any file in the computer on version control.
Umm… Okay… But Why Tho?
Here’s Why:
A Version Control System (VCS) allows you to revert files back to a previous state, revert the entire project back to a previous state, review changes made over time, see who last modified something that might be causing a problem, who introduced an issue and when, and more. Using a VCS also means that if you screw things up or lose files, you can generally recover easily. And sometimes you just want to know “who wrote this crap”, and having access to that information is worthwhile ?.
So What is Git?
Git is a version-control system for tracking changes in computer files and coordinating work on those files among multiple people. Git is a Distributed Version Control System. So Git does not necessarily rely on a central server to store all the versions of a project’s files. Instead, every user “clones” a copy of a repository (a collection of files) and has the full history of the project on their own hard drive. This clone has all of the metadata of the original while the original itself is stored on a self-hosted server or a third party hosting service like GitHub.
Git helps you keep track of the changes you make to your code. It is basically the history tab for your code editor(With no incognito mode ?). If at any point while coding you hit a fatal error and don’t know what’s causing it you can always revert back to the stable state. So it is very helpful for debugging. Or you can simply see what changes you made to your code over time.
In the example above, all three cards represent different versions of the same file. We can select which version of the file we want to use at any point of time. So I can jump to and fro to any version of the file in the git time continuum.
Git also helps you synchronise code between multiple people. So imagine you and your friend are collaborating on a project. You both are working on the same project files. Now Git takes those changes you and your friend made independently and merges them to a single “Master” repository. So by using Git you can ensure you both are working on the most recent version of the repository. So you don’t have to worry about mailing your files to each other and working with a ridiculous number of copies of the original file. And collaborating long distance becomes as easy as HTML ?.
Git Workflow:
Before we start working with Git commands, it is necessary that you understand what it represents.
What is a Repository ?
A repository a.k.a. repo is nothing but a collection of source code.
There are four fundamental elements in the Git Workflow.
Working Directory, Staging Area, Local Repository and Remote Repository.
If you consider a file in your Working Directory, it can be in three possible states.
- It can be staged. Which means the files with the updated changes are marked to be committed to the local repository but not yet committed.
- It can be modified. Which means the files with the updated changes are not yet stored in the local repository.
- It can be committed. Which means that the changes you made to your file are safely stored in the local repository.
git add
is a command used to add a file that is in the working directory to the staging area.git commit
is a command used to add all files that are staged to the local repository.git push
is a command used to add all committed files in the local repository to the remote repository. So in the remote repository, all files and changes will be visible to anyone with access to the remote repository.git fetch
is a command used to get files from the remote repository to the local repository but not into the working directory.git merge
is a command used to get the files from the local repository into the working directory.git pull
is command used to get files from the remote repository directly into the working directory. It is equivalent to agit fetch
and agit merge
.
Now that we know what Git is and it’s basic terminologies, let’s see how we can place a file under git. We’re going to do it the right way and the difficult way. Without any GUI applications. Neat video download mac free.
I’m assuming you already have a file the you want to place under version control. If not create a sample folder named ‘MuskCult’ and place some sample code files in it.
Step 0: Make a GitHub Account. Duh.
If you don't already have one, you can make one here. Elgato eyetv treiber download mac.
Step 1: Make sure you have Git installed on you machine.
If you are on a Mac, fire up the terminal and enter the following command:
This will prompt open an installer if you don’t already have git. So set it up using the installer. If you have git already, it’ll just show you which version of git you have installed.
If you are running Linux(deb), enter the following in the terminal:
If you are on Windows:
Just kidding… Relax… The amount of people I triggered… Phew…
Go to this link or thislink for more info on how to get it.
Step 2: Tell Git who you are.
Introduce yourself. Slide in. Seriously, mention your Git username and email address, since every Git commit will use this information to identify you as the author.
Step 3: Generate/check your machine for existing SSH keys. (Optional)
Why you ask? Using the SSH protocol, you can connect and authenticate to remote servers and services. With SSH keys, you can connect to GitHub without supplying your username or password at each visit.
Follow thislinkto learn more about SSH.
Go hereto check if you have an existing SSH key.
Go here to generate a SSH Key.
Go hereto add the SSH key to your GitHub account.
And finally go here to test its connection.
If you did setup SSH, every git command that has a link you replace it by:
I’ll be using SSH protocol in this tutorial.
Step 4: Let’s Git
Create a new repository on GitHub. Follow this link.
Now, locate to the folder you want to place under git in your terminal.
Initialize Git:
And to place it under git, enter:
Now go edit the README.md file to provide information about the repository.
Add files to the Staging Area for commit:
Now to add the files to the git repository for commit:
Before we commit let’s see what files are staged:
Commit Changes you made to your Git Repo:
Now to commit files you added to your git repo:
Uncommit Changes you just made to your Git Repo:
Now suppose you just made some error in your code or placed an unwanted file inside the repository, you can unstage the files you just added using:
Add a remote origin and Push:
Now each time you make changes in your files and save it, it won’t be automatically updated on GitHub. All the changes we made in the file are updated in the local repository. Now to update the changes to the master:
The git remote command lets you create, view, and delete connections to other repositories.
The git remote -v command lists the URLs of the remote connections you have to other repositories.
Now the git push command pushes the changes in your local repository up to the remote repository you specified as the origin.
And now if we go and check our repository page on GitHub it should look something like this:
And that’s it. You’ve just added the files to the repository you just created on GitHub.
See the Changes you made to your file:
Once you start making changes on your files and you save them, the file won’t match the last version that was committed to git. To see the changes you just made:
Revert back to the last committed version to the Git Repo:
Now you can choose to revert back to the last committed version by entering:
View Commit History:
You can use the git log command to see the history of commit you made to your files:
Each time you make changes that you want to be reflected on GitHub, the following are the most common flow of commands:
Now if we go and see our repo, we can identify whether the commit was successful by looking at the commit message for each file.
Step 5 : That’s all well and good… But How do I download and work on other repositories on GitHub?
Cloning a Git Repo:
Locate to the directory you want to clone the repo. Copy the link of the repository you want and enter the following:
Feel free to go ahead and clone the repo I created above using: https://github.com/Gothamv/MuskCult
Pushing Changes to the Git Repo:
Now you can work on the files you want and commit to changes locally. If you want to push changes to that repository you either have to be added as a collaborator for the repository or you have create something known as pull request. Go and check out how to do one here and give me a pull request with your code file.
Collaborating:
So imagine you and your friend are collaborating on a project. You both are working on the same project files. Each time you make some changes and push it into the master repo, your friend has to pull the changes that you pushed into the git repo. Meaning to make sure you’re working on the latest version of the git repo each time you start working, a git pull command is the way to go.
Now below is an example of a project my friend and I are collaborating on:
So to make sure those changes are reflected on my local copy of the repo:
Here’s two more useful git commands:
In the simplest terms, git fetch
followed by a git merge
equals a git pull
. But then why do these exist?
When you use git pull
, Git tries to automatically do your work for you. It is context sensitive, so Git will merge any pulled commits into the branch you are currently working in. git pull
automatically merges the commits without letting you review them first.
When you git fetch
, Git gathers any commits from the target branch that do not exist in your current branch and stores them in your local repository. However, it does not merge them with your current branch. This is particularly useful if you need to keep your repository up to date, but are working on something that might break if you update your files. To integrate the commits into your master branch, you use git merge
.
One More Thing:
So what is it?
.gitignore
tells git which files (or patterns) it should ignore. It's usually used to avoid committing transient files from your working directory that aren't useful to other collaborators, such as compilation products, temporary files IDEs create, etc.
So in the above example, files like __pycache__, .DS_Store are used by the system to store information for faster access. This is not useful for other collaborators. So we can tell git to ignore them by adding a .gitignore
file.
Use the touch command to create the .gitignore
file:
And you can add the following patterns to tell git to ignore such files.
And that’s pretty much it for the basics. Stay tuned for Part 2 which will focus on Branch, Merge, Stash, Rebase etc.
If you enjoyed the article, don’t forget to smash that Clap button and make sure you follow me for Part 2.
Peace Out ✌️
References :
Adding an existing project to GitHub using the command line - User Documentation
Putting your existing work on GitHub can let you share and collaborate in lots of great ways. If you are migrating your…help.github.comHow to undo (almost) anything with Git
One of the most useful features of any version control system is the ability to 'undo' your mistakes. In Git, 'undo'…blog.github.comGit on the commandline - Don't be afraid to commit 0.3 documentation
There are other ways of installing Git; you can even get a graphical Git application, that will include the commandline…dont-be-afraid-to-commit.readthedocs.ioStart using Git on the command line GitLab
Documentation for GitLab Community Edition, GitLab Enterprise Edition, Omnibus GitLab, and GitLab Runner.docs.gitlab.comWhat is the difference between 'git pull' and 'git fetch'?
Moderator Note: Given that this question has already had sixty-seven answers posted to it (some of them deleted)…stackoverflow.com
You can’t use Git until you make it available on your computer. There are a couple different ways you can install Git and make it available for use. The option you choose will depend on the system you are running.
In this article, I will show you how to install Git on a MAC OS, as well as how to install Git on LINUX.
A couple of things you will want to make note of while interacting with Git.
- Even if you already have Git installed it is a good idea to update to the latest version.
- All of the commands below should work, even on the older versions of Git. They may act a little differently but should work. Git is very good at preserving backward compatibility. Any version after 2.0 should work just fine.
How To Install Git on MAC OS
There are a couple of ways to install Git on MAC OS. The easiest way to do it would probably be to install the Xcode Command Line Tools. This will work on Mavericks (10.9) or above, so it should cover you. If you are running on OS older than that I would recommend you look into upgrading that first.
If your MAC OS is good to go simply run git from the Terminal the very first time. Here is what that would look like:
If it isn’t installed you will be prompted to install. If it is installed, then the above command should output the current version installed.
If you need or want a more up-to-date version, then you can install Git on MAC OS via a binary installer. There is a MAC OS Git installer that is maintained and made available for download on the Git website, at https://git-scm.com/download/mac.
Finally, a third option of installing Git on MAC OS is to install it as part of the GitHub for MAC install.
They have a GUI Git tool that has an option to install command line tools as well. You can download this tool from the GitHub for MAC website, at https://mac.github.com.
How To Install Git on Linux
More often than not you can install Git on Linux via a binary installer through the package management tool that comes with your distribution.
If you’re on Fedora or other closely related RPM-based distribution, like RHEL or CentOS, you can use dnf:
$ sudo dnf install git-all
If you happen to be on a Debian-based distribution, like Ubuntu, try using apt:
Git Mac Download
Installation For Other Unix Distributions
Gentoo
# emerge –ask –verbose dev-vcs/git
Arch Linux
openSUSE
# zypper install git
Mageia
Nix/NixOS
# nix-env -i git
FreeBSD
Solaris 9/10/11 (OpenCSW)
# pkgutil -i git
Solaris 11 Express
OpenBSD
# pkg_add git
Alpine
Slitaz
$ tazpkg get-install git
Author: Jeremy Holcombe
Growing up in Hawaii, Jeremy started his freelance writing career doing resumes, business plans, article writing, and everything in between. He now specializes in online marketing and content writing and is part of the Content Marketing Team at GreenGeeks.