Streamlining the usage of Github with Commands

1. Start a new git repository under one directory locally

git add -n . #to see what will be added

2. Connect it to github and push files

git status # to check the current state
$ git remote add origin git@github.com:username/new_repo.git
$ git push -u origin master
$ git remote add origin https://github.com/username/newrepo.git
$ git push -u origin master
git remote set-url origin https://yourusername@github.com/user/repo.git

Problem

git push -u origin mastererror: src refspec master does not match any.
error: failed to push some refs to 'http://stash.company.com/scm/PROJECT/REPO.git'

Cause

Resolution

touch initialgit add initialgit commit -m "initial commit"git push -u origin master
git push origin <your_branch_name> --force
vi .git/config
$ git remote set-url origin git@github.com:ppreyer/first_app.git
$ git remote add github git@github.com:ppreyer/first_app.git

3. Others

git remote -v origin git@github.com:USERNAME/REPOSITORY.git (fetch) origin git@github.com:USERNAME/REPOSITORY.git (push)
git remote set-url origin https://github.com/USERNAME/REPOSITORY.git
git remote -v # Verify new remote URL origin https://github.com/USERNAME/REPOSITORY.git (fetch) origin https://github.com/USERNAME/REPOSITORY.git (push)
git remote -v origin https://github.com/USERNAME/REPOSITORY.git (fetch) origin https://github.com/USERNAME/REPOSITORY.git (push)
git remote set-url origin git@github.com:USERNAME/REPOSITORY.git
git remote -v # Verify new remote URL origin git@github.com:USERNAME/REPOSITORY.git (fetch) origin git@github.com:USERNAME/REPOSITORY.git (push)
origin  https://github.com/ZZUTK/Face-Aging-CAAE.git (fetch)
origin https://github.com/ZZUTK/Face-Aging-CAAE.git (push)
$ git checkout -b branch_name #give it a new branch name
$ git add .
$ git commit .
$ git push origin branch_name

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store