Git Guide - nullstar/SecondBrain GitHub Wiki

Access Private Repository

  • Sign in to github.com on a web browser
  • Using the dropdown in the top right corner navigate to Settings > Developer settings > Personal access tokens. !PersonalAccessToken01.png !PersonalAccessToken02.png
  • Select Generate new token and create the token type you want. For most cases you probably want to add Contents to the Permissions when using fine-grained tokens. Copy the token generated. !PersonalAccessToken03.png !PersonalAccessToken04.png !PersonalAccessToken05.png
  • Now when you perform Git actions on the command line you should be prompted for the token. Paste the token into the window that pops up. !PersonalAccessToken06.png
  • When you are done you can go back to the Personal access tokens page on Github and delete unwanted tokens or just wait for them to expire.

Clone Repository

  • Sign in to github.com on a web browser
  • Navigate to the repository you wish to clone on Github. From the Code tab click on the <> Code dropdown button to get the clone URL. !CloneRepo01.png
  • From a command line navigate to the directory you wish to hold your git repos and use the following command:
git clone [url] [name]

[url] is the url link you copied from github, [name] is optional and is the name of the folder you wish to clone into. If no name is included a folder will created that matches the name of the repo.

Check Status

To check on the status of a workspace, navigate to that workspace on the command line and use:

git status

Workflow

Starting A New Feature

  • Navitage to your workspace on the command line.
  • Create a new branch off the master to develop the feature in:
git checkout master
git checkout -b [featureBranchName]

Working On A Feature

  • Navitage to your workspace on the command line.
  • Check you are in the correct branch:
git branch
  • If you are in the wrong branch you can change braches using:
git checkout [featureBranchName]
  • Make sure the workspace is up to date by pulling the latest from the repo:
git pull
  • Make your local changes to the workspace.
  • Add your local changes to the changelist:
git add .
  • Commit your changelist with a comment:
git commit -m "My Comment"
  • Push your commited changelist to the repo:
git push

Merge Features Into A Release Branch

  • Create a new branch off master to hold your release:
git checkout master
git checkout -b [releaseBranchName]
  • For each feature branch, merge those features into the release branch:
git merge [featureBranchName]
  • If you are done with the feature branches you can delete them using:
git branch -d [featureBranchName]
  • You can now test your release branch and fix any problems it has after merging all the features together.

Merge The Release Branch Back Into Master

  • When the release branch is ready you can merge this back into the master:
git checkout master
git merge [releaseBranchName]
  • If you are done with the release branche you can delete it using:
git branch -d [releaseBranchName]
⚠️ **GitHub.com Fallback** ⚠️