Git
Table of Contents
Adding a remote
View remote
Removing remote
Getting Started
Global User Configuration
Create New Git Project
Before going to terminal, create new repository in github website & note down the <repository-name>
Add files to Existing Repo
Navigate to your file location on terminal and add remote
Generate SSH
Stash
Stashing is the term git uses for saving your changes before taking pull.
Note: <stash-name> is needed if you work on multiple saves otherwise you can skip and type git stash to save and git stash apply or git stash pop to retrieve.
Branch
Merge & Rebasing
Branches are good for developing features to your software, the below steps walk you through creating, rebasing and merging.
Creation
Rebasing — Rebase to make sure we sync our feature branch with master
Squash — all you branch commits to one commit with meaningful message
Merge your branch to master
Commit
Tag
Amend last remote commit
Multiple github accounts
Reference — Nettuts, Arnaudrinquin
Remote
Adding a remote
To add a new remote, navigate to project path in terminal.
The git remote add command takes two arguments:
A remote name, for example,
originA remote URL, for example,
https://github.com/user/repo.git
View remote
Remove remote
Avoid git push requires username, password everytime
A common mistake is cloning using the default (HTTPS) instead of SSH. You can correct this by going to your repository, clicking the ssh button left to the URL field and updating the URL of your origin remote like this:
Move git files with commits from the old to the new repo
Navigate to the old repo path eg. cd /works/old-repo/
Last updated