Add new file, change file, delete file to existing repository:
git remote add origin https://github.com/trivan/GrailsExamples.git
git pull -u origin master
git push -u origin master
Tutorial from Github:
Create a new repository on the command line
touch README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/trivan/GrailsExamples.git
git push -u origin master
Push an existing repository from the command line
git remote add origin https://github.com/trivan/GrailsExamples.git
git push -u origin master
OR
So, you have been working on a project locally and then decide you really should version control it and share it with the world. One option would be to create the repository on Github, clone it locally and then copy all the files across. But it does not have to be so messy. Here is how you add an existing project to Github without cloning it first.
Go to your project
Commit the files.
Go to the Github page for the repo. You will should see the URL for the Github repo, which you need to copy.
Add this as the remote origin:
You should see something like this:
git remote add origin https://github.com/trivan/GrailsExamples.git
git pull -u origin master
git add -A
stages Allgit add .
stages new and modified, without deletedgit add -u
stages modified and deleted, without new
git push -u origin master
Tutorial from Github:
Create a new repository on the command line
touch README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/trivan/GrailsExamples.git
git push -u origin master
Push an existing repository from the command line
git remote add origin https://github.com/trivan/GrailsExamples.git
git push -u origin master
OR
So, you have been working on a project locally and then decide you really should version control it and share it with the world. One option would be to create the repository on Github, clone it locally and then copy all the files across. But it does not have to be so messy. Here is how you add an existing project to Github without cloning it first.
Create git repo locally
We need to add a repository for your project. Git is a distributed version control system, so each machine has its own repository. This is different to centralised version control systems like Subversion, which have a single, central, repository.Go to your project
$ cd my_project
Initialise the repository$ git init
You should see the following message:Initialized empty Git repository in /path/to/my_project/.git/
Add all your files to the repo:$ git add *
Check to see that there are changes to be committed:$ git status
You should see something like this:# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: my_project.info
# new file: my_project.module
#
In this case, my_project.info and my_project.module are the files I have in my project.Commit the files.
$ git commit -m "First commit"
You should see something like this:[master (root-commit) 8201309] First commit
2 files changed, 74 insertions(+), 0 deletions(-)
create mode 100644 my_project.info
create mode 100644 my_project.module
Create Github project
Head over to Github and create a new project.Add Github as remote origin
Now we need to push our changes to Github.Go to the Github page for the repo. You will should see the URL for the Github repo, which you need to copy.
Add this as the remote origin:
$ git remote add origin https://github.com/yourname/my_project.git
Pull from Github to local:And finally, push the code to Github:git
pull
-u origin master
git push -u origin master
You should see something like this:
Counting objects: 7, done.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 1.71 KiB, done.
Total 6 (delta 0), reused 0 (delta 0)
To https://github.com/yourname/my_project.git
ba2316b..3dae654 master -> master
That is all there is to it! Now your project is under version control and public on Github.
Không có nhận xét nào:
Đăng nhận xét