Git Guide: Difference between revisions

From iSchool Reference
(Create page)
 
mNo edit summary
Line 1: Line 1:
= Access Tokens =
= 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. [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.


== Installing Git ==
==Installing Git==
If you don’t already have Git on your computer, you’ll need to [https://git-scm.com/book/en/v2/Getting-Started-Installing-Git install it].
If you don’t already have Git on your computer, you’ll need to [https://git-scm.com/book/en/v2/Getting-Started-Installing-Git install it].


= Git Commands =
=Git Commands=


== git clone ==
====== git clone ======
Download a copy of a repository into a new directory.
Download a copy of a repository into a new directory.


== git checkout [-b] ==
====== git checkout [-b] ======
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 . ==
====== git add . ======
Place new files under version control.
Place new files under version control.


== git status ==
====== git status ======
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] ==
====== git commit [-am] ======
Record changes that you’ve made to the repository.
Record changes that you’ve made to the repository.


Line 28: Line 29:
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 ==
====== git push ======
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 ==
====== git merge ======
Join two branches together.
Join two branches together.


== git log ==
====== git log ======
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] ==
====== git branch [-D] ======
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 ==
====== git pull ======
Retrieve the latest commits on a branch from a remote repository.
Retrieve the latest commits on a branch from a remote repository.


== git fetch ==
====== git fetch ======
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 18:35, 1 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.

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”