Question

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

I'm new to GitHub 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.

Was it helpful?

Solution

Since I wrote this answer, github released a native windows client which makes all the below steps redundant.

You can also use sourcetree to get both git and mercurial setup on Windows.


Here is how you would do it in Windows:

  1. If you don't have git installed, see this article on how to set it up.
  2. Open up a Windows command prompt.
  3. Change into the directory where your source code is located in the command prompt.
  4. First, create a new repository in this directory git init. This will say "Initialized empty git repository in ....git" (... is the path).
  5. Now you need to tell git about your files by adding them to your repository. Do this with git add filename. If you want to add all your files, you can do git add .
  6. Now that you have added your files and made your changes, you need to commit your changes so git can track them. Type git commit -m "adding files". -m lets you add the commit message in line.

So far, the above steps is what you would do even if you were not using github. They are the normal steps to start a git repository. Remember that git is distributed (decentralized), means you don't need to have a "central server" (or even a network connection), to use git.

Now you want to push the changes to your git repository hosted with github. You do this by telling git to add a remote location, and you do that with this command:

git remote add origin https://github.com/yourusername/your-repo-name.git

*Note: your-repo-name should be created in GitHub before you do a git remote add origin ... Once you have done that, git now knows about your remote repository. You can then tell it to push (which is "upload") your commited files:

git push -u origin master

OTHER TIPS

How to upload a project to Github from scratch

Follow these steps to project to Github

1) git init

2) git add .

3) git commit -m "Add all my files"

4) git remote add origin https://github.com/yourusername/your-repo-name.git

Upload of project from scratch require git pull origin master.

5) git pull origin master

6) git push origin master

git push --force origin master

if you have problems uploading!

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 :)

Follow these steps to upload your project to Github

1) git init

2) git add .

3) git commit -m "Add all my files"

4) git remote add origin https://github.com/yourusername/your-repo-name.git

Upload of project from scratch require git pull origin master.

5) git pull origin master

6) git push origin master

If any problem occurs in pushing use git push --force origin master

Follow these two steps:

  1. Create the repository online using the link: https://github.com/new
  2. Then link your local repo to the remote repo using the command: git add remote origin https://github.com/userName/repo.git Here the repo.git will be your newly created remote repo.

This will work like a charm. No need to worry about the SSH or HTTPS ways. I first faced the same issue and spent hours for solution. But this worked for me.

Create a new repository on GitHub. To avoid errors, do not initialize the new repository with README, license, or gitignore files. You can add these files after your project has been pushed to GitHub. Open Terminal (for Mac users) or the command prompt (for Windows and Linux users).

Change the current working directory to your local project.

Initialize the local directory as a Git repository.

git init
#Add the files in your new local repository. This stages them for the first commit.

git add
# Adds the files in the local repository and stages them for commit. To unstage a file, use 'git reset HEAD YOUR-FILE'. Commit the files that you've staged in your local repository.

git commit -m 'First commit'
#Commits the tracked changes and prepares them to be pushed to a remote repository. To remove this commit and modify the file, use 'git reset --soft HEAD~1' and commit and add the file again.

  1. At the top of your GitHub repository's Quick Setup page, click enter image description here to copy the remote repository URL. At the top of your GitHub repository's Quick Setup page, click to copy the remote repository URL.
  2. 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 # Sets the new remote git remote -v # Verifies the new remote URL Note: GitHub for Windows users should use the command git remote set-url origin instead of git remote add origin here. Push the changes in your local repository to GitHub.

$ git push origin master
# Pushes the changes in your local repository up to the remote repository you specified as the origin.

Source Attribution: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/

This worked for me;

1- git init
2- git add .
3- git commit -m "Add all my files"
4- git remote add origin https://github.com/USER_NAME/FOLDER_NAME
5- git pull origin master --allow-unrelated-histories
6- git push origin master

I assume you are on a windows system like me and have GIT installed. You can either run these commands by simple command prompt in the project directory or you can also use GitBash.

Step 1: Create a repository in GIT manually. Give it whatever name you seem fit.

Step 2: Come to your local project directory. If you want to publish your code to this new repository you just created make sure that in the projects root directory there is no folder name .git, if there is delete it. Run command git init

Step 3: Run command git add .

step 4: Run command git commit -m YourCommitName

Step 5: Run command git remote add YourRepositoryName https://github.com/YourUserName/YourRepositoryName.git

Step 6: Run Command git push --set-upstream YourRepositoryName master --force

Please note that I am using the latest version of GIT at the time of writing. Also note that I did not specify any particular branch to push the code into so it went to master. In step 6 the GIT will ask you to authorize the command by asking you to enter username and password in a popup window.

Hope my answer helped.

  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

Steps to upload project to git:-

step1-open cmd and change current working directory to your project location.

step2-Initialize your project directory as a Git repository.

$ git init

step3-Add files in your local repository.

$ add .

step4-Commit the files that you've staged in your local repository.

$ git commit -m "First commit"

step5-Copy the remote repository url.

step6-add the remote repository url as origin in your local location.

$ git add origin copied_remote_repository_url

step7-confirm your origin is updated ot not.

$ git remote show origin

step8-push the changed to your github repository

$ git push origin master.

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!

  1. First You have to create an account on Github
  2. Then create new Project - name that Project as you want then your project url is shown
  3. Now copy the url
  4. Then open Command Prompt and go to the directory or folder which you want to upload using cmd
  5. Then type the following Commands

     git init
     git add .
     git commit -m "initial commit"
     git remote add origin PASTE URL
     git push -u origin master
    
  6. Now check your GitHub account, Repository is successfully uploaded.

For Complete guidance, you can watch this video.

It took me like 1-2 hours to realize that I'm supposed to create repository to GitHub before trying to push my local files to github (or what ever git service you're using).

After trying to push errors were like:

remote: Repository not found.
fatal: repository 'https://github.com/username/project.git/' not found

I feel like an idiot, but I really would like to emphasize this for beginners like me. I just thought that my repo will be created automatically during the first push. I was so wrong.

edit: you can se your remotes with command

git remote -v

Probably the most useful thing you could do is to peruse the online book [http://git-scm.com/book/en/]. It's really a pretty decent read and gives you the conceptual context with which to execute things properly.

Download SourceTree. It is available for windows7+ and Mac and is highly recommend to upload files on github via interactive UI.

Make sure that git is installed on your system. I'm explaining the process using windows OS

Here is how I did :

1.Open the cmd (you can do with git bash as well).

2.Go to your project directory(where your project is located).

3.Now type your_directory >git init this will initialize an empty repository if it is first time and enter. for eg :C:\Users>git init

4.Now type your_directory >git add <filename>(if specific files) or git add . (if you want to add all files) and enter.

5.Now type >git commit -m "commit message goes here" and enter.

(in case if you need to check the status you can do by typing >git status) and enter.

6.Now type >git remote add origin git_repository_url

(check>git remote -v) and enter.

7.Now turn to push it ...>git push origin master and enter

(if you get error you push it forcefully by typing ...>git push -f origin master and enter.

Now you're done with adding it to your repository. Refresh it and it will be there in your created repository.

Hopefully, this will work for you.

Follow the instruction from RishiKesh Pathak above, you can even short the push command by inserting this command line one time only:

git config --global push.default simple

So next time instead of using git push origin master you just need:

git push

See details here.

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

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

  1. We need Git Bash
  2. In Git Bash Command Section::

1.1 ls

It will show you default location.

1.2 CD "C:\Users\user\Desktop\HTML" We need to assign project path

1.3 git init It will initialize the empty git repository in C:\Users\user\Desktop\HTML

1.4 ls It will list all files name

1.5 git remote add origin https://github.com/repository/test.git it is your https://github.com/repository/test.git is your repository path

1.6 git remote -v To check weather we have fetch or push permisson or not

1.7 git add . If you put . then it mean whatever we have in perticular folder publish all.

1.8 git commit -m "First time"

1.9 git push -u origin master

What you need it an SSH connection and GitHub init into your project. I will explain under Linux machine.

Let's start with some easy stuff: navigate into your project in the terminal, and use:

git init
git add .
git commit 

now let's add SSH into your machine: use ssh-keygen -t rsa -C "your_email@example.com" and copy the public key, then add it to your GitHub repo Deploy keys -> add one back to your machine project now launch: git push origin master if there is an error config your .github/config by nano .github/config and change the URL to ssh one by url = git@github.com:username/repo.... and that's it

Try using Git Bash to push your code/make changes instead of uploading files directly on GitHub (it is less prone to errors and is quite comfortable at times - takes less time as well!), for doing so, you may follow the below-given steps:

  1. Download and install the latest version of Git Bash from here - https://git-scm.com/
  2. Right-click on any desired location on your system.
  3. Click “Git Bash Here”.
  4. git config --global user.name “your name”
  5. git config --global user.email “your email”
  6. Go back to your GitHub account – open your project – click on “clone” – copy HTTPS link.
  7. git clone PASTE HTTPS LINK.
  8. Clone of your GitHub project will be created on your computer location.
  9. Open the folder and paste your content.
  10. Make sure content is not empty
  11. Right-click inside the cloned folder where you have pasted your content.
  12. Click “Git Bash Here” again.
  13. You will find (master) appearing after your location address.
  14. git add .
  15. Try git status to check if all your changes are marked in green.
  16. git commit --m “Some message”
  17. git push origin master

for uploading a new project into GIT (first you need to have local code base of project and the GIT repo where you will be uploading project ,in GIT you need to have your credentials)

  1. List item

    1.open Git Bash

    2 . go to the directory where you have the code base (project location ) cd to project location cd /*/***/*****/***** Then here you need to execute git commands

    1. git init press enter then you will see something like this below Initialized empty Git repository in *:/***/****/*****/.git/ so git init will initialize the empty GIT repository at local
    2. git add . press enter the above command will add all the directory,sub directory , files etc you will see something like this warning: LF will be replaced by CRLF in ****. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in ********. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in *******. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in ********. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in *******. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in **************. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in ************. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in *************** The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in j*******. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in ***********. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in **************. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in ***********. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in *********. The file will have its original line endings in your working directory.

    3. git commit -m "first commit" press enter -m provided option for adding comment it will commit the code to stage env you will see some thing like this

[master (root-commit) 34a28f6] adding ******** warning: LF will be replaced by CRLF in c*******. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in *******. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in ********. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in *********. The file will have its original line endings in your working directory.

warning: LF will be replaced by CRLF in ***********.


27 files changed, 3724 insertions(+) create mode 100644 ***** create mode 100644 ***** create mode 100644 ***** create mode 100644 ****** create mode 100644 ****** create mode 100644 ***** create mode 100644 ******

6.git remote add origin http://username@git:repopath.git press enter this will add to repo

7.git push -u origin master press enter this will upload all from local to repo in this step you need to enter password for the repo where you will be uploading the code. you will see some thing like this below Counting objects: 33, done. Delta compression using up to 12 threads. Compressing objects: 100% (32/32), done. Writing objects: 100% (33/33), 20.10 KiB | 0 bytes/s, done. Total 33 (delta 14), reused 0 (delta 0) To http://username@git:repolocation.git * [new branch] master -> master Branch master set up to track remote branch master from origin.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top