I have repository in GitHub. I edited files in my PC, committed them and now I want to push these files to GitHub. How can I do it?
If the files are already cloned from a github repository git push will do it.
cd /path/to/repo
git push
If this local repo does not belong to any github repo, create a repository in github. This will give you a git repo url like git://github.com/username/project.git. Now you need to add this url as remote to your existing local repository
cd /path/to/repo
git remote add origin git://github.com/username/project.git
Then you can commit your changes and push it
git push
Go to github and create a repository under your account (if you haven't already). If you've done that, follow the instructions for pushing code from an already existing repository.
Related
I'm new to git and GitHub so sorry if this question is simplistic. A vendor has developed the WordPress theme for our website and has created GitHub repo of the theme. We want to clone the theme to our an organization which has been set up on our enterprise GitHub account. However, I'm not quite understanding the process for the process for doing this. When I search cloning it's the answer always is discusses cloning from a GitHub repo to a local repo, whereas we want to clone from a private GitHub repo to a repo in the setup in our organization.
Transferring a repo would mean you are the owner of the original repo.
If you are not the owner of that vendor theme repository, you do have to clone it locally, and then:
change its remote to refer to a new empty repo created in your GitHub organisation
push everything
That is:
git clone --mirror git#github.com:user/repo.git
cd repo.git
git remote set-url origin git#yourGitHUb.com:org/empty-repo.git
git push --mirror
In this case,I guess you need to transfer the ownership of the repo. You can refer this
https://help.github.com/articles/transferring-a-repository/
Hope this helps!
EDIT 1:If you just need a copy of the original repo (Note: further changes in original repo will not reflect in yours unless you do a pull after forking it)
https://help.github.com/articles/fork-a-repo/
I have files for a website in a folder on my computer that I'd like to put on GitHub. Do I create a repository in GitHub Desktop first or create a repository on GitHub first? And once I have a repository what is the very first thing I do to move those files into the repository? This may be a stupid question but I've made a mess of things and I'm very confused at this point.
Create a repository on GitHub
git clone your new repository on your computer
Copy the files you want to push to your repository inside the new folder created by cloning
git add --all to add all these files for commit
git commit -m "Initial commit" to create a commit
git push to push this commit to your GitHub repository
remote: Repository not found.
fatal: repository 'https://github.com/vivekghanchi/portfolio.git/' not found
You need first to create your repository in GitHub (it's done directly in your Web browser). Then you can do a git push to upload your local commits to the new repository.
Also, after creating your GitHub repository, make sure the url you are pushing to matches that of GitHub, I notice an extra / at the end of your url, which should not be there.
To see the url you are pushing to, issue:
git remote -v
the repository is deleted but I was committing to a new repository after than also it is showing this
Committing is a local operation.
Make sure your remote url matches the one of your new repo.
Update it with:
cd /path/to/my/local/repo
git remote set-url https://github.com/vivekghanchi/aNewRepo
Then try to push again:
git push
Pushing is not "committing to GitHub", but rather "publishing your local commits to your upstream GitHub repository".
You need first to create your repository in GitHub (it's done directly in your Web browser). Then you can do a git push to upload your local commits to the new repository.
Committing is a local operation.
or your can add already existing repo
git remote add origin remote repository URL
I need to export an Eclipse project to GitHub. I am using Eclipse-Mars with the eGit plugin. I have spent hours reading documentation, tutorials, and posts and see that there are basically two ways
Create an Eclipse project and a local Git repository. Commit to local repository. Create a repository on GitHub. Push the Eclipse project to the repository on GitHub. When I try this, I get the error "rejected non-fast-forward". I have no idea why. I did create a .gitignore on GitHub when I created the repository - is that causing a problem?
Create a repository on GitHub. In Eclipse, clone this repository and then add files. Commit to local repository, then push. This works, but I end up with a weird configuration on GitHub:
reponame/myprojname/src
when I would prefer the more normal
reponame/src
Which method is the correct way to proceed? Why do I get the push error in the first method, and why the strange folder layout in the second?
You first need to pull the github code into you local machine.
=> git remote add origin
=> git pull origin master
will automatically fetch and merge the github repo with your local copy. You may need to resolve some conflicts that could be generated due to 3-way merge.
After all this, you can use -
=> git push -u origin master
For the second Point,
If you want src/ directory directly under reponame/ on github, then you should execute git clone after creating the project in eclipse and git clone should be executed inside the myprojectname/ directory.
When you created the .gitignore file on GitHub, you created a commit in the repository that isn't in your local copy. You'll need to add the GitHub repo as a remote, pull the change, and then push your local changes:
git remote add origin <path to your repository>
git pull origin master
git push -u origin master
I have a project in Eclipse that I want to put on github, so I went to github and created the repos for them, but I want to clone them right into the folder where the files are stored in my eclipse workspace. How can I do this?
EDIT: When I try it, the github app says it can't clone because the folder isn't empty.
EDIT 2: Will this work? Changing the name in eclipse to rename the project folder, then cloning the repo to the name I want, in the workspace, then renaming the eclipse project so they merge and I can commit the new files.
GitHub has a guide explaining how to put an existing project on GitHub.
You should not clone the repository, but add the GitHub repository as a remote to a local repository you create yourself.
Go to your project folder and initialize a local repository with git init
Add and commit all your project files to the local repository. (e.g. git add . and git commit -m "message")
Add the GitHub repository as a remote. git remote add origin *github repository URL* (Verify with git remote -v)
Push your project to GitHub with git push origin master.
If you already have committed files to the GitHub repository, it is still possible.
Initialize your local repository.
Add GitHub as the remote.
Pull from GitHub.
Add and commit your project.
Push you project to GitHub
First add the remote as follows
git remote add origin <GIT URL>
Then simply do the following (MAke sure to commit any of your local files)
git pull --allow-unrelated-histories