Git Guide: Difference between revisions
mNo edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
= Getting Started = | = Getting Started = | ||
==Access Tokens == | ==Access Tokens == | ||
In order to access iSchool repos on GitHub Education, you’ll need to create a personal access token, which will be used like a password. [https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token#creating-a-personal-access-token-classic Follow the steps in the GitHub documentation] to create your personal access token. | In order to access iSchool repos on GitHub Education, you’ll need to create a personal access token, which will be used like a password. [https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token#creating-a-personal-access-token-classic Follow the steps in the GitHub documentation] to create your personal access token. Make sure you save your access token someplace where you'll be able to find it again; once you leave the GitHub page where the token was created, you won't be able to see it there again. | ||
Note that when you're prompted for a password, like when calling <code>git push</code>, you actually need to enter your access token. | |||
==Installing Git== | ==Installing Git== | ||
Line 8: | Line 10: | ||
=Git Commands= | =Git Commands= | ||
====== git clone ====== | ======<code>git clone</code>====== | ||
Download a copy of a repository into a new directory. | Download a copy of a repository into a new directory. | ||
====== git checkout [-b] ====== | ======<code>git checkout [-b]</code>====== | ||
Switch to a different branch; specify the -b flag to create a new branch. | Switch to a different branch; specify the -b flag to create a new branch. | ||
====== git add . ====== | ======<code>git add .</code>====== | ||
Place new files under version control. | Place new files under version control. | ||
====== git status ====== | ======<code>git status</code>====== | ||
Show the current state of the working tree (i.e., the files that you’re working on). | Show the current state of the working tree (i.e., the files that you’re working on). | ||
Use the -s flag for a shortened view. | Use the -s flag for a shortened view. | ||
====== git commit [-am] ====== | ======<code>git commit [-am]</code>====== | ||
Record changes that you’ve made to the repository. | Record changes that you’ve made to the repository. | ||
Line 29: | Line 31: | ||
Use the -m flag to include a commit message; best practice is to preface your commit message with the ticket ID for whatever task you’re working on. | Use the -m flag to include a commit message; best practice is to preface your commit message with the ticket ID for whatever task you’re working on. | ||
====== git push ====== | ======<code>git push</code>====== | ||
Update the remote repository (i.e., GitHub Classroom) with the changes that you’ve committed to your local repository. | Update the remote repository (i.e., GitHub Classroom) with the changes that you’ve committed to your local repository. | ||
====== git merge ====== | ======<code>git merge</code>====== | ||
Join two branches together. | Join two branches together. | ||
====== git log ====== | ======<code>git log</code>====== | ||
See a history of commits for your current branch. | See a history of commits for your current branch. | ||
Use “git log --graph --decorate --oneline” for a concise view. | Use “git log --graph --decorate --oneline” for a concise view. | ||
====== git branch [-D] ====== | ======<code>git branch [-D]</code>====== | ||
See the name of the branch that you’re currently on. | See the name of the branch that you’re currently on. | ||
Use the -D flag to delete the branch. | Use the -D flag to delete the branch. | ||
====== git pull ====== | ======<code>git pull</code>====== | ||
Retrieve the latest commits on a branch from a remote repository. | Retrieve the latest commits on a branch from a remote repository. | ||
====== git fetch ====== | ======<code>git fetch</code>====== | ||
Get the list of available branches from a remote repository; often needed before “git pull” | Get the list of available branches from a remote repository; often needed before “git pull” |
Revision as of 12:04, 19 April 2023
Getting Started
Access Tokens
In order to access iSchool repos on GitHub Education, you’ll need to create a personal access token, which will be used like a password. Follow the steps in the GitHub documentation to create your personal access token. Make sure you save your access token someplace where you'll be able to find it again; once you leave the GitHub page where the token was created, you won't be able to see it there again.
Note that when you're prompted for a password, like when calling git push
, you actually need to enter your access token.
Installing Git
If you don’t already have Git on your computer, you’ll need to install it.
Git Commands
git clone
Download a copy of a repository into a new directory.
git checkout [-b]
Switch to a different branch; specify the -b flag to create a new branch.
git add .
Place new files under version control.
git status
Show the current state of the working tree (i.e., the files that you’re working on).
Use the -s flag for a shortened view.
git commit [-am]
Record changes that you’ve made to the repository.
Use the -a flag to automatically include files that you’ve modified or deleted; you’ll still need to use “git add .” to include any new files that you’ve created.
Use the -m flag to include a commit message; best practice is to preface your commit message with the ticket ID for whatever task you’re working on.
git push
Update the remote repository (i.e., GitHub Classroom) with the changes that you’ve committed to your local repository.
git merge
Join two branches together.
git log
See a history of commits for your current branch.
Use “git log --graph --decorate --oneline” for a concise view.
git branch [-D]
See the name of the branch that you’re currently on.
Use the -D flag to delete the branch.
git pull
Retrieve the latest commits on a branch from a remote repository.
git fetch
Get the list of available branches from a remote repository; often needed before “git pull”