ref – http://stackoverflow.com/questions/17291995/push-existing-project-into-github
ref – https://help.github.com/articles/fork-a-repo/
Create the repo
Make sure you have created a repository on Github via
https://github.com/new
Enter a repository name, then check the box where it creates a readme file.
Click ok.
Fork
Then fork it locally, directions below are taken from the url here: https://help.github.com/articles/fork-a-repo/
Directions
On GitHub, navigate to your fork of your repository.
Clone URL buttonIn the right sidebar of your fork’s repository page, click
to copy the clone URL for your fork.
Open Terminal (for Mac users) or the command prompt (for Windows and Linux users).
Type git clone, and then paste the URL you copied in Step 2. It will look like this, with your GitHub username instead of YOUR-USERNAME:
1 |
$git clone https://github.com/YOUR-USERNAME/REPO-NAME |
Press Enter. Your local clone will be created and the output from your terminal will be something like this:
Rickys-MacBook-Pro:Desktop rickytsao$ git clone https://github.com/redmacdev1988/face-recognizer.git
Cloning into ‘face-recognizer’…
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
Checking connectivity… done
Clone a single branch
git clone https://your_name@gitcn.company.com:1234/hehe-haha/hehe-haha.git –branch dev
Clone with username
1 |
git clone https://username:password@github.com/username/repository.git |
List branches of the the repository
(double dash next to “heads”)
git ls-remote –heads https://git.yourcompany.com/some_person/project_name.git
Change working branch :
Create the branch on your local machine and switch in this branch :
$ git checkout -b [name_of_your_new_branch]
Change working branch :
$ git checkout [name_of_your_new_branch]
Push the branch on github :
$ git push origin [name_of_your_new_branch]
Uploading Project
Then, you’ll see the project folder on your desktop. Copy your source files into the folder. And to upload it to Github you do:
note – The project url can be found on the repo page on the righthand side bar. It should have a little paste icon next to it. Its the HTTPS clone URL…you should be able to just copy and paste to the terminal window
If the system tell you that origin already exists, keep going with the instructions.
Make sure you are in the directory of the folder that Git created on your computer. Then within the folder (which should have a git file) you go:
1 2 3 4 5 |
git init git add . git commit -m "Initial commit" git remote add origin <project url> git push -f origin master |
Rickys-MacBook-Pro:holistic-element rickytsao$ git push -f origin master
It will then ask you for your username and password:
Username for ‘https://github.com’: redmacdev1988
Password for ‘https://redmacdev1988@github.com’:
result:
Counting objects: 651, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (645/645), done.
Writing objects: 100% (650/650), 130.74 MiB | 1.45 MiB/s, done.
Total 650 (delta 19), reused 0 (delta 0)
To https://github.com/redmacdev1988/holistic-element.git
0ddae45..a74a112 master -> master
If you want to remove files, delete the files in your directory.
Then in the same directory, go:
git commit -a -m “removed fluff”
git push origin master
Pulling (cloning) the project onto your machine
git clone https://git.epam.com/ricky_tsao/badmintoneventsapp.git
src refspec does not match any ERROR
If you try pushing to a certain branch and it gives you a src refspec error, it means you are not on that branch. You need to switch to that branch first, THEN, push to it.
git checkout -b Ricky_Tsao
Switched to a new branch Ricky_Tsao
git commit -a -m “cleaned up stuff”
git push origin Ricky_Tsao
Cloning Single Branch
git clone learned –single-branch option to limit cloning to a single branch;
tags that do not point into the history of the branch are not fetched.
1 |
git clone -b mybranch --single-branch git://sub.domain.com/repo.git |
git clone -b branch_name –single-branch (double dash in front of “single”) https://gitcn.epam..com:1234/your_name/project_name.git
Merge current local branch with remote
$ git stash
$ git pull origin release/1.0.1
// fix conflicts
// git add, git commit
$ git stash pop
// git add, git commit, git push
See the list of files that have changes between your local and remote
$ git status
On branch dev
Your branch is up-to-date with ‘origin/dev’.
Changes to be committed:
(use “git reset HEAD
modified: Src/Project/Website/Code/global/css/product.css
modified: Src/Project/Website/Code/global/standalonesim.html
Stash
$ git stash save “—–”
$ git stash list
$ git stash apply stash@{0}
Delete local branch
$ git branch -d feature/login
Pushing new files onto your branch
$ git add .
$ git reset build/config (or whatever path to folder you want to exclude)
$ git commit -m “Add existing file”
$ git push -f origin Your_Branch