In this lesson, we'll cover common Git commands used to manage your projects and to upload your work onto GitHub. We refer to these commands as the basic Git workflow. When you're using Git, these are the commands that you'll use 70-80% of the time, so if you can get these down, you'll be more than halfway done mastering Git!
how to copy an existing repository from Github onto your local machine?
- using the
clone
command. - Use
git clone git@github.com:<your-github-username>/<your-respository-name>
Explain the two-stage system that Git uses to save files.
- A save in Git is divided into two terminal commands:
add
andcommit
. The combination of these two commands gives you control of exactly what you want to be remembered in your snapshot. - Staging: Think of
add
as adjusting the number of people or elements to be included in a photo. With Git, you can select the changes you want to save withgit add
. Imagine a project that contains multiple files where changes have been made to several files. You want to save some of the changes you have made and leave some other changes to continue working on them. - Committing: Think of
commit
as actually taking a photo, resulting in a snapshot. For example, to commit a file named README.md, typegit commit -m "Add README.md"
. The-m
flag stands for "message" and must always be followed by a commit message inside quotation marks. In this example, the commit message was"Add README.md"
.
Describe how to upload your work to GitHub using Git
- using the
push
command
Describe how to check the status of your files
- Use
git status
to see any changes made since your last commit.
how to view your commit history?
- using the
git log
command
What is the Git command used to track files with Git?
- Use
git add
to track files.
Explain what origin
is in git push origin master
.
- In Git,
origin
is a placeholder name for the URL of the remote repository. Git sets up the origin by default when it clones a remote repository. You can useorigin
to access the remote repository without having to enter a full URL every time. This also means that you can have multiple remotes for a repository by giving each a unique name. - If there is only one remote to the repository, you can use
git push
directly.
Explain what master
is in git push origin master
..
- In Git,
master
is the branch of the remote repository you want to push your changes to. We will get more into branches in a later lesson, but the main thing to remember is thatmaster
is the official branch in your projects where production-ready code lives.
How to createa a new branch?
- In Git, to create a new branch, use
git branch <branchname>
- The basic Git syntax is
program | action | destination
. - For further content about Git & GitHub: Click Me
- see this article : github in plain english
- learn Git with Bitbucket
- for more help:
- Local Git Manuals:
man git
,git --help
. - for a specific command:
git remote --help
.
- Local Git Manuals: