Git and GitHub
Git and GitHub
Before you start reading the guide, please remember the following statement:
The very same cloned repo in different places on your PC will have
different package references id's after you manipulate the original repo!
Second path =Desktop cloned repo First path = Original cloned repo
One clone ory
My PC n e r e posit
O
GitHub
so
One GitHub Repository will contain only one cloned version of that repo
on your local PC!
Don't make multiple clones of this repo on local machine.
Okay?
Road Map
The general idea and the flow chart behind this guide
GitHub
My PC Server
Response ( i'm giving you want you asked for)
Cloned
repo
Html Config
Html
Html file
w files
Adding ne
My local
Project
e st
Adding files to
qu
Cloned repo re
● git clone
● git add
Config
● git commit
file
● git push
Confirm
modified
changes repo
Git and GitHub Source Control
Part1 (Working on a new repository)
The Complete Web Developer in 2018: Zero to Mastery
Step 1
●
Navigate to https://github.com
●
Start a new project
Step 2
●
Name your project background-generator
●
Select Public
●
Check to create a README file
●
Finally click create repository button
Step 3
●
Click Clone or download button
●
Select use HTTPS
●
Copy the URL to a clipboard by clicking the Little
icon
Step 4
●
Open terminal(bash,or powershell) or other prefered
terminal.
●
Navigate to a project you currently work on.
●
Enter the following commad:
git clone https://github.com/antonykidis/background-generator.git
●
Here is the following output
Unpacking objects 100% (6 / 6) done.
The background-generator cloned now to your computer
We've just copied our repo to a local computer.
You can see the background-generator appeared in the left window
Step 5
Next Step is to take all of our local project's files and folders, and copy them into the background-generator repository folder.
You can copy these files using the IDE, or a command line (terminal)
To copy files and folders via command line please refer to the terminal section of the course
Illustration
Step 6
1. Back to a terminal window and cd (navigate) to a newly created
cloned direcory named background-generator.
Example:
cd background-generator
2. Then type ls (dir in windows) to
list the contents of a background-generator folder.
3. You should see the similar output with all the copied files from the
previous step.
Step 7
Step 8
● Let's Add utracked files to a special Configuration
file
Type the following commands:
● git add CSS (folder)
● git add Script(folder)
● git add Scope.js(file)
● git add index.html (file)
To add all files and folders at once type git add .
Step 9
● After adding each file, and folder
Step 10
● Let's commit previously added files and folders.
● Enter the following command
● git commit -m ''adding starting project''
Step 11
Step 12
1. For example:
open index.html and change the title<h1>here</h1>
to a cool generator
2. Save it
3. Comeback to a terminal window, and type
git status
You should see a similar output
4. Type git add (adding the index.html)
5. Type git commit -m ''title has been changed''
(save changes)
6. Type git push (pushing the changes back to
server)
7.Go to
GitHub
Navigate to commits link
And see the actual changes we've just made
As you can see the title has been changed to a Cool Generator
We can pull the latest version from GitHub
Useful
commands
git add <files, or folders> Adds a new files to repo(via config file)
git rm <files or folders> Removes files, or folders from GitHub
git add . Adds all files and folders
git commit Save changes to config file, and prepare
pushing it to the server
git push Pushes the new changes back to server, and
updates the remote repository
git pull Pulls the latest version of the repository from a
GitHub
git status Checks the overall status of repository
git branch -d branch_name Removes the named branch
or git branch -D branch_name
Removes the last commit mistakenly pushed to the GitHub
git revert dd61ab32 By commit ID. So the commit id in this case is dd61ab32
git push origin --delete <branch_name> Delete a remote GIT branch
git push <remote_name> :<branch_name>
Delete a remote GIT branch
Remote name means this:
git push origin :<branch_name>