How to upload a project to Github

2019-01-08 03:07发布

After checking this question I still have no idea how to get a project uploaded to my Git Hub repository.

I'm new to Git Hub and I have no idea what to do. I created a Repository but i want to upload my project to it.

I've looked on the repository page for an upload button of some kind but I haven't seen anything of the sort.

I've looked at the links provided so far but I'm still getting no where. They mention command line, is that Windows command line or Git Bash? Because I can't get either to do anything.

I also tried using Git GUI but when I select the folder I want it says that it's not a Git repository...does it need to be zipped up? I tried adding the .gitconfig file in the folder but it doesn't make a difference.

Thanks in advance :)

17条回答
不美不萌又怎样
2楼-- · 2019-01-08 03:16

I did as follows;

  1. git init
  2. git add .
  3. git commit -m "Your_message"
  4. git remote add origin @your_git_repository
  5. git push -u origin master

Of course you have to install git

查看更多
闹够了就滚
3楼-- · 2019-01-08 03:17

The best way to git is to actually start Gitting. Try out this website which makes you go step by step on what are the essential ways for performing functions on command line for pushing a Project on GitHub

This is called try.github.io or you could also take up a course on codeAcademy

查看更多
家丑人穷心不美
4楼-- · 2019-01-08 03:19
git push --force origin master

if you have problems uploading!

查看更多
三岁会撩人
5楼-- · 2019-01-08 03:20

I think the easiest thing for you to do would be to install the git plugin for eclipse, works more or less the same as eclipse CVS and SVN plugins:

http://www.eclipse.org/egit/

GL!

查看更多
三岁会撩人
6楼-- · 2019-01-08 03:27
  1. Open Git Bash.
  2. Change the current working directory to your local project.
  3. Initialize the local directory as a Git repository: $ git init
  4. Add the files in your new local repository. This stages them for the first commit: $ git add .
  5. Commit the files that you've staged in your local repository: $ git commit -m "First commit"
  6. At the top of your GitHub repository's Quick Setup page, click to copy the remote repository URL.
  7. In the Command prompt, add the URL for the remote repository where your local repository will be pushed : $ git remote add origin remote repository URL
  8. Push the changes in your local repository to GitHub: $ git push origin master
查看更多
Bombasti
7楼-- · 2019-01-08 03:28

Here I explain how I did it on Window, maybe it also helps others :)

Make sure to install Git and GitHub.

After installation is complete, open “git bash”;

enter image description here

so a window like below is gonna pop up:

enter image description here

Go ahead and type cd ~ to make sure you are on home directory;

You can check the address that you are in it by typing pwd;

Now you need to create a GitHub account;

After creating a GitHub account, go ahead and sign in;

After you signed in, on the top right click on the + and choose “New Repository”

enter image description here

Then in the opened window, type the name that you wish to have for the repository in the “Repository name” box. Add “Description (optional)” if you like, and mark “Initialize this repository with a README”. Then click on “Create repository”.

enter image description here

Now go to your C driver; create a new folder and name it “git” Now go to the “git bash” window; change the directory to c drive by typing cd ~; cd /c If you type ls there it would show you the folders there; Make sure it shows the git folder there:

enter image description here

Now go back to the browser; go to your GitHub page, click on the repository that you made; and click on “Clone or download”; and copy the address that shows there (by choosing copy to clipboard)

enter image description here

Now going back to “git bash”; Use the command cd git to go to the git folder; now write the following commands to connect to your GitHub (enter the username and password of your GitHub when it asks you)

git config --global user.name "Your Name"

And then: git config --global user.email youremail@domain.com . Next type: git clone (url), instead of the (url), type the address of the GitHub repository that you copied from your GitHub page; (e.g. git clone https://github.com/isalirezag/Test.git).

Now if you do ls command you will see your repository there; If you also open the git folder that you have in your window you will see that your repository is added as a folder.

Now use the cd command to go to the repository: cd Test

Go ahead and copy and paste any files that you want to put in this repository in that folder.

In order to transfer the files to your repository you need to do following now:

Type git

add filename (filename is the file name that you want to upload) or you can type the command below if you want to add all the files in the folder:

git add .

Then type: git commit -m "adding files" . And then: git push -u origin master .

And then you should be all set, if you refresh your GitHub account the files should be there :)

查看更多
登录 后发表回答