GitHub Basics - Derek Bable

GitHub Basics
Derek Babel 2017 spring
Github: DerekBable
GitHub Basics
- HOW TO SET UP A GITHUB ACCOUNT AND ADD THE STUDENT DEVELOPER PACK
(WHICH GRANTS UNLIMITED FREE PRIVATE REPOSITORIES).
- SOME BASIC TERMINOLOGY
- SOME BASIC TUTORIALS ON HOW TO MANAGE GITHUB REPOSITORIES, BOTH ON THE
WEB AND WITH THE COMMAND LINE.
Some Terminology
 Repository
 A sort of "file system" with version control in which files can be uploaded to.
 Local Repository
 A repository that exists on a computer's (your computer's) hard drive.
 Remote Repository
 A repository that exists on a server's (in this case, GitHub's servers) storage.
 Private Repository
 A remote repository that is not browsable on GitHub.com by anyone except the
repository owner and contributors (as defined by the owner) of the repository.
 Public Repository
 A remote repository that is browsable on GitHub.com by anyone, but the owner or
contributors must approve commits to the repository.
Creating a GitHub Account and Adding
the Student Developer Pack
 Go to GitHub.com
 In the text boxes in the middle of the screen, enter the following
information:
 Pick a username: the user name you want associated with your GitHub account,
as well as displayed with any commits you make to repositories.
 Your email address: the email you want associated with your account (you can
use your YSU email, but you don't have to), also shown on commits.
 Password: the password you want associated with your account.
1
GitHub Basics - Derek Bable
Creating a GitHub Account and Adding
the Student Developer Pack
 On the "Choose your personal plan" page, leave "Unlimited public
repositories for free" checked, click continue.
 Enter information relevent to you and click next, or click "Skip this step"
2
GitHub Basics - Derek Bable
Creating a GitHub Account and Adding
the Student Developer Pack
 Go to https://education.github.com/pack, click "Get your pack"
 Click "Yes, I'm a student"
 Enter the information as it applies to you, click "Submit Request"
 If you did not use your YSU email for your GitHub account, you will need to
follow the steps to add it as a contact for your GitHub account.
 You should receive an email saying that your account was upgraded with
the Student Developer Pack. You can now create private repositories.
 Note, this may take some time. It took a few hours for me, but can take days.
3
Creating a New GitHub Repository
 Go to GitHub.com and sign in with your account username and password
 Click "Start a Project"
 Select the options you want for your repository, click "Create Repository"
 You should initialize your project with a readme if creating a new repository.
The readme displays on the main page of your repository.
1
GitHub Basics - Derek Bable
Creating a New GitHub Repository
 After clicking create, you just made your initial commit to your repository.
Now, you can manage your repository on the Web, or using Git on the
command line.
2
Some Terminology (Git)
 Commits
 Commits are the way in which you update changes to files in your repository.
After making a change to a file, you need to commit it in order for the changes
to be reflected in your repository.
 Push
 Push refers to pushing committed changes from your local repository to your
server repository. IF you don't have any changes committed in your local
repository and you try to push, nothing will happen.
 Pull
 Pull refers to pulling changes from a remote repository to your local repository.
1
Some Terminology (Git)
 Merge Conflicts / Conflicts
 Conflicts arise when multiple commits have been made to a file which conflict
with eachother. Conflicts can be carefully resolved as to make sure the files are
in tact and correctly updated.
 You probably won't have many conflicts if you are the only one working on your
repository.
2
Some Terminology (Git)
 Branches
 When you create a repository, you create one branch, the master branch. You
can create other branches to keep a separate "folder" for other code.
 By convention, the Master Branch is supposed to be an always working code branch.
If you branch from Master, you get a copy of the content's of Master into the branch
you just created.
 Branching is done to add new or experimental features to existing code in a way that
does not ruin the main branch of code.
 Pull Requests
 You can generate a pull request to pull a branch into master.
3
Managing a GitHub Repository (Web)
 Commits on the Web
 If you edit a file on GitHub.com, you can simply choose to commit and push the
file to the branch you are in at the bottom of the file editor page.
 Pushing and Pulling on the Web
 Depending on how you are changing files on the Web, remember, you are
working with the remote repository, so once you commit a change, your
repository is immediately updated with the change, you do not need to push in
this case.
 You can create pull requests on the Web to pull branches into one another.
1
Managing a GitHub Repository (Web)
 Adding Collaborators to a Repository
 When at the main page of a repository you own, you can add collaborators
by clicking the '+' icon in the top right of the page and click "New
Collaborator"
 You will then enter the username of the person's GitHub account that you want
to add.
 You probably want to add Dr. Yu, his username is: fenggeorgeyu
2
Managing a GitHub Repository
(Command Line)
 This guide assumes you are using Windows as an Operating System. Git is
available for other platforms, but the installation will differ. Once you have Git
installed, the "Using Git" section is universal.
 Get Git
 Go to https://git-scm.com/ and download Git for your OS (Windows was used for this
guide with Git version 2.11.0)
 Pick your architecture (I recommend against the portable version unless you
know what you are doing) [64-Bit was used for this guide].
 Run the installer you downloaded
 "Git-2.11.0.3-64-bit.exe" was used for this guide.
 You can simply leave everything as default in the installation procedure. If you
change settings, you will need to account for them later in this guide.
1
Managing a GitHub Repository
(Command Line)
 You will notice that there are multiple programs that were installed relating
to Git: 1) Git GUI: A graphical interface for creating, cloning, and opening
repositories. 2) Git CMD: A command line (Windows) type interface for
using Git. 3) Git Bash: A Unix type interface for using Git.
 Here, I will use Git Bash, but Git CMD works very similarly.
 If using Linux, use one of the following commands to install Git based on
your Linux Distribution:
 Debian/Ubuntu
 sudo apt-get install git (or, if you are root, simply: apt-get install git)
2
Managing a GitHub Repository
(Command Line)
 Linux Fedora
 yum install git (up to Fedora 21)
 dnf install git (Fedora 22 and later)
 Gentoo
 emerge --ask --verbose dev-vcs/git
 Arch Linux
 pacman -S git
 openSUSE
 zypper install git
3
Managing a GitHub Repository
(Command Line)
 FreeBSD
 cd /usr/ports/devel/git
 make install
 Solaris 9/10/11 (OpenCSW)
 pkgutil -i git
 Solaris 11 Express
 pkg install developer/versioning/git
 OpenBSD
 pkg_add git
 Alpine
 apk add git
4
Managing a GitHub Repository
(Command Line): Cloning a Repo
 Git Bash (Cloning a Repository)
 Assuming that you created a repository online, you can now use Git to
clone your repository to your computer's hard drive.
 Open Git Bash
 Git Bash uses Unix (Linux, Ubuntu, etc) type commands (i.e. ls, mkdir, etc.)
 On open, Git Bash will put you into your C:Users**YourUserName folder.
 Create a new folder here (either with Windows Explorer or...) by typing
"mkdir 'nameOfFolder', where 'nameOfFolder' is the name of the folder you
want to create.
 For this guide, I used "mkdir MyRepository"
5
Managing a GitHub Repository
(Command Line): Cloning a Repo
 Now, we can clone a remote repository into our local repository (which will
be located in the directory we just created)
 Type: "git clone {pathToRemoteRepository} ./MyRepository"
 Here, {pathToRemoteRepository} will be the URL of the repository from GitHub
you want to clone, for example: https://github.com/DerekBable/CTL-Main-
Server
 For this guide, I used: "git clone https://github.com/DerekBable/CTL-Main-
Server ./MyRepository/"
 If necessary, you will be asked for GitHub credentials to clone the repository.
6
GitHub Basics - Derek Bable
Managing a GitHub Repository
(Command Line): Cloning a Repo
 Now, "cd" into the repository: "cd MyRepository"
 You will notice some extra text at the end of your current line in Command Line
that says "~/MyRepository (master)"
 This means your current directory is identified as a repository, and you are
currently in the master branch.
7
GitHub Basics - Derek Bable
Managing a GitHub Repository
(Command Line)
 While in a repository directory on your machine, you can use Git to
manage your local repository and push it to your remote repository.
8
Managing a GitHub Repository
(Command Line): Pull
 First, it's a good idea to pull any changes made since the last time you
pulled to your local repository.
 To do this, type "git pull"
 If the local and remote repositories are in sync already, you will get a return of
"Already up-to-date"
9
Managing a GitHub Repository
(Command Line): Create/Edit Files
 To create or edit files in a local repository, you can simply use File Explorer,
command line, or whatever means you wish, your local repository is
essentially the same as a normal directory on your machine.
 For example, open up your repository's directory in your File Explorer and
create a new file in it.
 For this guide, I created a new text document "Test.txt"
10
GitHub Basics - Derek Bable
Managing a GitHub Repository
(Command Line): Adding Files
 IMPORTANT: If you create a new file or folder like this, you
need to add that folder or file to Git.
 To do this, type "git add fileName.ext" where fileName.ext is the file
name and extension of the file you just created.
 For this guide, using the above example, "git add Test.txt"
11
Managing a GitHub Repository
(Command Line): Deleting Files
 If you just delete a file in File Explorer, Git will not
stop tracking the file, the file will just simply be
removed from your local repostiory and not your
remote repository. To remove a file from Git and get
it to stop tracking the file (so you can actally commit
the removed file), use "git rm" instead.
 For example, "git rm Test.txt"
12
Managing a GitHub Repository (Command Line): Adding
Files
Managing a GitHub Repository
(Command Line): Committing
 After you have changed your local repository in some way
(adding, removing, or editing a file) you need to commit your
changes to the repository, then push them to the remote
repository.
 To do this, make some changes to your repository (i.e. adding a file in
the above step) then type "git commit -m
{someShortMessageAboutWhatYouDid}"
 The "-m" flag adds a message to your commit. It is good practice to
include a message with every commit you do.
 For example, "git commit -m "Created Test.txt file."
13
Managing a GitHub Repository
(Command Line): Push
 After commiting changes to your local repository,
you need to push those changes to the remote
repostiory.
 To do this, type "git push“
 Now, if you go to your repository on the web, you will see
your commited changes take effect in your remote
repository.
14
Important Notes
 You should almost always pull before you start working with your repository.
 In almost every case, you need to commit before you push (or else no changes
will be reflected).
 Creating a new file in a File Explorer requires you to add the file to Git after
creation using “git add {file}”
 Deleting a file in a File Explorer will not remove the file from Git, instead, use
Git Bash and use “git rm {file}”
1 von 34

Recomendados

Git training v10Git training v10
Git training v10Skander Hamza
911 views64 Folien
Git basicsGit basics
Git basicsGHARSALLAH Mohamed
1.2K views38 Folien
Github basicsGithub basics
Github basicsRadoslav Georgiev
16.9K views28 Folien
GithubGithub
GithubMeetPatel710
753 views20 Folien

Más contenido relacionado

Was ist angesagt?(20)

Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHub
Nicolás Tourné10.7K views
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notes
glen_a_smith3.5K views
Introduction to GitIntroduction to Git
Introduction to Git
Lukas Fittl6.5K views
Git and github 101Git and github 101
Git and github 101
Senthilkumar Gopal1.4K views
Introduction to github slideshareIntroduction to github slideshare
Introduction to github slideshare
Rakesh Sukumar24.6K views
Intro to Git and GitHubIntro to Git and GitHub
Intro to Git and GitHub
Panagiotis Papadopoulos2.7K views
git and githubgit and github
git and github
Darren Oakley13.1K views
Introduction to Git and GithubIntroduction to Git and Github
Introduction to Git and Github
Somkiat Puisungnoen2.4K views
Learning gitLearning git
Learning git
Sid Anand2.4K views
Workshop on Git and GitHubWorkshop on Git and GitHub
Workshop on Git and GitHub
DSCVSSUT258 views
Intro to Git, GitHub, and BitBucketIntro to Git, GitHub, and BitBucket
Intro to Git, GitHub, and BitBucket
Legal Services National Technology Assistance Project (LSNTAP)2.4K views
Git 101 for Beginners Git 101 for Beginners
Git 101 for Beginners
Anurag Upadhaya1.5K views
Introduction To GitIntroduction To Git
Introduction To Git
Arnaud Seilles3.4K views
Introduction to GitIntroduction to Git
Introduction to Git
Yan Vugenfirer14.4K views
Git real slidesGit real slides
Git real slides
Lucas Couto3.5K views
A Practical Introduction to gitA Practical Introduction to git
A Practical Introduction to git
Emanuele Olivetti4.8K views
Introduction to Git and GithubIntroduction to Git and Github
Introduction to Git and Github
Houari ZEGAI410 views
Git for beginnersGit for beginners
Git for beginners
Arulmurugan Rajaraman4.1K views

Destacado(9)

Git, GitHub and Open SourceGit, GitHub and Open Source
Git, GitHub and Open Source
Lorna Mitchell2.2K views
Git/GitHubGit/GitHub
Git/GitHub
Microsoft500 views
Inside GitHub with Chris WanstrathInside GitHub with Chris Wanstrath
Inside GitHub with Chris Wanstrath
SV Ruby on Rails Meetup67.2K views
Introduction to Git and GitHubIntroduction to Git and GitHub
Introduction to Git and GitHub
Bioinformatics and Computational Biosciences Branch46.1K views
Git and GithubGit and Github
Git and Github
Wen-Tien Chang15.7K views
Git and GitHubGit and GitHub
Git and GitHub
James Gray11.3K views
Quick Introduction to gitQuick Introduction to git
Quick Introduction to git
Joel Krebs24.9K views

Similar a GitHub Basics - Derek Bable

GitGit
GitAlf Chang
236 views20 Folien
Git/GitHubGit/GitHub
Git/GitHubCindy Royal
3K views3 Folien
GitGit
Gitzafarfaizi
743 views20 Folien

Similar a GitHub Basics - Derek Bable(20)

A Tutorial for GitHub.pdfA Tutorial for GitHub.pdf
A Tutorial for GitHub.pdf
Amarnadh3649 views
A Tutorial for GitHub.pdfA Tutorial for GitHub.pdf
A Tutorial for GitHub.pdf
badrfathallah22 views
GitGit
Git
Alf Chang236 views
Git/GitHubGit/GitHub
Git/GitHub
Cindy Royal3K views
GitGit
Git
zafarfaizi743 views
git.pptgit.ppt
git.ppt
ssuser10dcd7168 views
setting up a repository using GITsetting up a repository using GIT
setting up a repository using GIT
Ashok Kumar Satuluri205 views
16 Git16 Git
16 Git
Hadley Wickham664 views
GitGit
Git
Vijay Kani114 views
Get your Git on GitHubGet your Git on GitHub
Get your Git on GitHub
Runcy Oommen194 views
Git Hub PlatformGit Hub Platform
Git Hub Platform
Gaurav Ahluwalia420 views
BitBucket presentationBitBucket presentation
BitBucket presentation
Jonathan Lawerh10.3K views
GIT By SivakrishnaGIT By Sivakrishna
GIT By Sivakrishna
Nyros Technologies1.1K views
Getting started With GITGetting started With GIT
Getting started With GIT
GhadiAlGhosh131 views
Extra bit with gitExtra bit with git
Extra bit with git
Himanshu Agrawal838 views
Git within RStudioGit within RStudio
Git within RStudio
PaulinaJedynakPhD25 views
Git hub visualstudiocodeGit hub visualstudiocode
Git hub visualstudiocode
Rolands Krumbergs289 views
Git and git hub basicsGit and git hub basics
Git and git hub basics
prostackacademy162 views

Más de "FENG "GEORGE"" YU(6)

Último(20)

Tunable Laser (1).pptxTunable Laser (1).pptx
Tunable Laser (1).pptx
Hajira Mahmood21 views
Java Platform Approach 1.0 - Picnic MeetupJava Platform Approach 1.0 - Picnic Meetup
Java Platform Approach 1.0 - Picnic Meetup
Rick Ossendrijver24 views
Liqid: Composable CXL PreviewLiqid: Composable CXL Preview
Liqid: Composable CXL Preview
CXL Forum120 views
CXL at OCPCXL at OCP
CXL at OCP
CXL Forum203 views
The Research Portal of Catalonia: Growing more (information) & more (services)The Research Portal of Catalonia: Growing more (information) & more (services)
The Research Portal of Catalonia: Growing more (information) & more (services)
CSUC - Consorci de Serveis Universitaris de Catalunya59 views
METHOD AND SYSTEM FOR PREDICTING OPTIMAL LOAD FOR WHICH THE YIELD IS MAXIMUM ...METHOD AND SYSTEM FOR PREDICTING OPTIMAL LOAD FOR WHICH THE YIELD IS MAXIMUM ...
METHOD AND SYSTEM FOR PREDICTING OPTIMAL LOAD FOR WHICH THE YIELD IS MAXIMUM ...
Prity Khastgir IPR Strategic India Patent Attorney Amplify Innovation24 views
ChatGPT and AI for Web DevelopersChatGPT and AI for Web Developers
ChatGPT and AI for Web Developers
Maximiliano Firtman161 views

GitHub Basics - Derek Bable

  • 1. GitHub Basics Derek Babel 2017 spring Github: DerekBable
  • 2. GitHub Basics - HOW TO SET UP A GITHUB ACCOUNT AND ADD THE STUDENT DEVELOPER PACK (WHICH GRANTS UNLIMITED FREE PRIVATE REPOSITORIES). - SOME BASIC TERMINOLOGY - SOME BASIC TUTORIALS ON HOW TO MANAGE GITHUB REPOSITORIES, BOTH ON THE WEB AND WITH THE COMMAND LINE.
  • 3. Some Terminology  Repository  A sort of "file system" with version control in which files can be uploaded to.  Local Repository  A repository that exists on a computer's (your computer's) hard drive.  Remote Repository  A repository that exists on a server's (in this case, GitHub's servers) storage.  Private Repository  A remote repository that is not browsable on GitHub.com by anyone except the repository owner and contributors (as defined by the owner) of the repository.  Public Repository  A remote repository that is browsable on GitHub.com by anyone, but the owner or contributors must approve commits to the repository.
  • 4. Creating a GitHub Account and Adding the Student Developer Pack  Go to GitHub.com  In the text boxes in the middle of the screen, enter the following information:  Pick a username: the user name you want associated with your GitHub account, as well as displayed with any commits you make to repositories.  Your email address: the email you want associated with your account (you can use your YSU email, but you don't have to), also shown on commits.  Password: the password you want associated with your account. 1
  • 6. Creating a GitHub Account and Adding the Student Developer Pack  On the "Choose your personal plan" page, leave "Unlimited public repositories for free" checked, click continue.  Enter information relevent to you and click next, or click "Skip this step" 2
  • 8. Creating a GitHub Account and Adding the Student Developer Pack  Go to https://education.github.com/pack, click "Get your pack"  Click "Yes, I'm a student"  Enter the information as it applies to you, click "Submit Request"  If you did not use your YSU email for your GitHub account, you will need to follow the steps to add it as a contact for your GitHub account.  You should receive an email saying that your account was upgraded with the Student Developer Pack. You can now create private repositories.  Note, this may take some time. It took a few hours for me, but can take days. 3
  • 9. Creating a New GitHub Repository  Go to GitHub.com and sign in with your account username and password  Click "Start a Project"  Select the options you want for your repository, click "Create Repository"  You should initialize your project with a readme if creating a new repository. The readme displays on the main page of your repository. 1
  • 11. Creating a New GitHub Repository  After clicking create, you just made your initial commit to your repository. Now, you can manage your repository on the Web, or using Git on the command line. 2
  • 12. Some Terminology (Git)  Commits  Commits are the way in which you update changes to files in your repository. After making a change to a file, you need to commit it in order for the changes to be reflected in your repository.  Push  Push refers to pushing committed changes from your local repository to your server repository. IF you don't have any changes committed in your local repository and you try to push, nothing will happen.  Pull  Pull refers to pulling changes from a remote repository to your local repository. 1
  • 13. Some Terminology (Git)  Merge Conflicts / Conflicts  Conflicts arise when multiple commits have been made to a file which conflict with eachother. Conflicts can be carefully resolved as to make sure the files are in tact and correctly updated.  You probably won't have many conflicts if you are the only one working on your repository. 2
  • 14. Some Terminology (Git)  Branches  When you create a repository, you create one branch, the master branch. You can create other branches to keep a separate "folder" for other code.  By convention, the Master Branch is supposed to be an always working code branch. If you branch from Master, you get a copy of the content's of Master into the branch you just created.  Branching is done to add new or experimental features to existing code in a way that does not ruin the main branch of code.  Pull Requests  You can generate a pull request to pull a branch into master. 3
  • 15. Managing a GitHub Repository (Web)  Commits on the Web  If you edit a file on GitHub.com, you can simply choose to commit and push the file to the branch you are in at the bottom of the file editor page.  Pushing and Pulling on the Web  Depending on how you are changing files on the Web, remember, you are working with the remote repository, so once you commit a change, your repository is immediately updated with the change, you do not need to push in this case.  You can create pull requests on the Web to pull branches into one another. 1
  • 16. Managing a GitHub Repository (Web)  Adding Collaborators to a Repository  When at the main page of a repository you own, you can add collaborators by clicking the '+' icon in the top right of the page and click "New Collaborator"  You will then enter the username of the person's GitHub account that you want to add.  You probably want to add Dr. Yu, his username is: fenggeorgeyu 2
  • 17. Managing a GitHub Repository (Command Line)  This guide assumes you are using Windows as an Operating System. Git is available for other platforms, but the installation will differ. Once you have Git installed, the "Using Git" section is universal.  Get Git  Go to https://git-scm.com/ and download Git for your OS (Windows was used for this guide with Git version 2.11.0)  Pick your architecture (I recommend against the portable version unless you know what you are doing) [64-Bit was used for this guide].  Run the installer you downloaded  "Git-2.11.0.3-64-bit.exe" was used for this guide.  You can simply leave everything as default in the installation procedure. If you change settings, you will need to account for them later in this guide. 1
  • 18. Managing a GitHub Repository (Command Line)  You will notice that there are multiple programs that were installed relating to Git: 1) Git GUI: A graphical interface for creating, cloning, and opening repositories. 2) Git CMD: A command line (Windows) type interface for using Git. 3) Git Bash: A Unix type interface for using Git.  Here, I will use Git Bash, but Git CMD works very similarly.  If using Linux, use one of the following commands to install Git based on your Linux Distribution:  Debian/Ubuntu  sudo apt-get install git (or, if you are root, simply: apt-get install git) 2
  • 19. Managing a GitHub Repository (Command Line)  Linux Fedora  yum install git (up to Fedora 21)  dnf install git (Fedora 22 and later)  Gentoo  emerge --ask --verbose dev-vcs/git  Arch Linux  pacman -S git  openSUSE  zypper install git 3
  • 20. Managing a GitHub Repository (Command Line)  FreeBSD  cd /usr/ports/devel/git  make install  Solaris 9/10/11 (OpenCSW)  pkgutil -i git  Solaris 11 Express  pkg install developer/versioning/git  OpenBSD  pkg_add git  Alpine  apk add git 4
  • 21. Managing a GitHub Repository (Command Line): Cloning a Repo  Git Bash (Cloning a Repository)  Assuming that you created a repository online, you can now use Git to clone your repository to your computer's hard drive.  Open Git Bash  Git Bash uses Unix (Linux, Ubuntu, etc) type commands (i.e. ls, mkdir, etc.)  On open, Git Bash will put you into your C:Users**YourUserName folder.  Create a new folder here (either with Windows Explorer or...) by typing "mkdir 'nameOfFolder', where 'nameOfFolder' is the name of the folder you want to create.  For this guide, I used "mkdir MyRepository" 5
  • 22. Managing a GitHub Repository (Command Line): Cloning a Repo  Now, we can clone a remote repository into our local repository (which will be located in the directory we just created)  Type: "git clone {pathToRemoteRepository} ./MyRepository"  Here, {pathToRemoteRepository} will be the URL of the repository from GitHub you want to clone, for example: https://github.com/DerekBable/CTL-Main- Server  For this guide, I used: "git clone https://github.com/DerekBable/CTL-Main- Server ./MyRepository/"  If necessary, you will be asked for GitHub credentials to clone the repository. 6
  • 24. Managing a GitHub Repository (Command Line): Cloning a Repo  Now, "cd" into the repository: "cd MyRepository"  You will notice some extra text at the end of your current line in Command Line that says "~/MyRepository (master)"  This means your current directory is identified as a repository, and you are currently in the master branch. 7
  • 26. Managing a GitHub Repository (Command Line)  While in a repository directory on your machine, you can use Git to manage your local repository and push it to your remote repository. 8
  • 27. Managing a GitHub Repository (Command Line): Pull  First, it's a good idea to pull any changes made since the last time you pulled to your local repository.  To do this, type "git pull"  If the local and remote repositories are in sync already, you will get a return of "Already up-to-date" 9
  • 28. Managing a GitHub Repository (Command Line): Create/Edit Files  To create or edit files in a local repository, you can simply use File Explorer, command line, or whatever means you wish, your local repository is essentially the same as a normal directory on your machine.  For example, open up your repository's directory in your File Explorer and create a new file in it.  For this guide, I created a new text document "Test.txt" 10
  • 30. Managing a GitHub Repository (Command Line): Adding Files  IMPORTANT: If you create a new file or folder like this, you need to add that folder or file to Git.  To do this, type "git add fileName.ext" where fileName.ext is the file name and extension of the file you just created.  For this guide, using the above example, "git add Test.txt" 11
  • 31. Managing a GitHub Repository (Command Line): Deleting Files  If you just delete a file in File Explorer, Git will not stop tracking the file, the file will just simply be removed from your local repostiory and not your remote repository. To remove a file from Git and get it to stop tracking the file (so you can actally commit the removed file), use "git rm" instead.  For example, "git rm Test.txt" 12 Managing a GitHub Repository (Command Line): Adding Files
  • 32. Managing a GitHub Repository (Command Line): Committing  After you have changed your local repository in some way (adding, removing, or editing a file) you need to commit your changes to the repository, then push them to the remote repository.  To do this, make some changes to your repository (i.e. adding a file in the above step) then type "git commit -m {someShortMessageAboutWhatYouDid}"  The "-m" flag adds a message to your commit. It is good practice to include a message with every commit you do.  For example, "git commit -m "Created Test.txt file." 13
  • 33. Managing a GitHub Repository (Command Line): Push  After commiting changes to your local repository, you need to push those changes to the remote repostiory.  To do this, type "git push“  Now, if you go to your repository on the web, you will see your commited changes take effect in your remote repository. 14
  • 34. Important Notes  You should almost always pull before you start working with your repository.  In almost every case, you need to commit before you push (or else no changes will be reflected).  Creating a new file in a File Explorer requires you to add the file to Git after creation using “git add {file}”  Deleting a file in a File Explorer will not remove the file from Git, instead, use Git Bash and use “git rm {file}”