Skip to content

Instantly share code, notes, and snippets.

@lg3bass
Last active December 23, 2020 18:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lg3bass/93b9a24ce678bc1acf54 to your computer and use it in GitHub Desktop.
Save lg3bass/93b9a24ce678bc1acf54 to your computer and use it in GitHub Desktop.
MACOS>UNIX>GIT>Create Repository From Existing
///NEW (2020-12-23)
1. Create a new repo on github. Make sure to not create a readme, licence, or git ignore. New repo MUST BE EMPTY!!!!
2. If you added NOTHING you will see the "Quick Setup" screen.
3. In your local repo (the folder you want to create the project from) run these commands in order:
LG3-MBP:ADSR lg3$ git init
LG3-MBP:ADSR lg3$ git add .
LG3-MBP:ADSR lg3$ git commit -m "enter a comment. What are you committing"
LG3-MBP:ADSR lg3$ git branch -M main
-- REF: https://docs.github.com/en/free-pro-team@latest/github/importing-your-projects-to-github/adding-an-existing-project-to-github-using-the-command-line
-- REF: https://www.git-tower.com/learn/git/faq/git-rename-master-to-main/
-- REF: https://stackoverflow.com/questions/64787301/git-init-b-branch-name-command-in-terminal-is-throwing-an-unknown-switch/64787736#64787736
-- IMPT: None of these references solved my problem!!! you need to use git branch -M main to change "master" to "main"
LG3-MBP:ADSR lg3$ git remote add origin https://github.com/lg3bass/MY-NEW-REPO.git
-- NOTE: get the url from the "Quick Setup" screen. Essentially this would the url on https://github.com
LG3-MBP:ADSR lg3$ git push -u origin main
4. You will see this message in terminal.
Counting objects: 90, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (77/77), done.
Writing objects: 100% (90/90), 1.98 MiB | 3.03 MiB/s, done.
Total 90 (delta 34), reused 0 (delta 0)
remote: Resolving deltas: 100% (34/34), done.
To https://github.com/lg3bass/MY-NEW-REPO.git
* [new branch] main -> main
Branch 'main' set up to track remote branch 'main' from 'origin'.
///OLD
# Follow the steps outlined here. These are generally very good.
https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line
# I did have an issue with my RSA key which i had to redo on the mac
https://help.github.com/articles/generating-ssh-keys/#step-4-add-your-ssh-key-to-your-account
# My steps are slightly different
1. Create a new repo on github.com. Do not create a readme NOR .gitignore.
2. Open a terminal at the folder you want to commit
3. $ git init
4. create .gitignore using $ touch .gitignore
5. bbedit .gitignore
//examples
# OS generated files #
######################
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
# OF #
######################
/bin/*.app
/bin/data/obj/
/bin/data/obj_old/
//another example
// ~/Documents/OpenFrameworks/of_v0.8.1_osx_release/apps/RESEARCH/animationMachine_rebuild/.gitignore
// add all the files to the git staging. You have to do the .gitignore first so it doesn't put in all the bulky files.
//otherwise it's a pain to remove. If you get stuck you can do $ git rm -r --cached <the-file-or-directory>
6. $ git add .
7. check what was added with $ git status -s
8. Commit files $ git commit -m 'First commit'
9. Goto the github page and copy the URL for the remote repository (e.g. https://github.com/lg3bass/ofxObjLoader_test6.git)
10. construct the following command $ git remote add origin https://github.com/lg3bass/ofxObjLoader_test6.git
11. check to make sure all is good $ git status -s -AND- $ git remote -v
(REMEMBER: 'git remote -v' -- Use this if you need to know where this is on github.com)
12. finally $ git push origin master
NOTES:
//Q: Say you want to remove the .git folder. This is essentially remove all reference to git. presumably to start a new git project.
//source: http://stackoverflow.com/questions/4754152/git-how-to-remove-git-tracking-from-a-project
$ rm -rf .git
//Q: I can't post repos. Let's check to make sure you have a RSA key
//source: https://help.github.com/articles/generating-ssh-keys/#step-4-add-your-ssh-key-to-your-account
//source: https://help.github.com/articles/error-permission-denied-publickey/
$ ssh -T git@github.com
//Q: I want to ignore media files. Make sure you put the path to the folder starting and ending with '/'
//source: https://gist.github.com/octocat/9257657
//source: https://help.github.com/articles/ignoring-files/
# OF #
######################
/bin/*.app
/bin/data/obj/
/bin/data/obj_old/
//Q: I messed up and pasted in the wrong remote url?
//https://help.github.com/articles/changing-a-remote-s-url/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment