How to commit a folder to gitHub - github

I am new to GitHub, able to create a README textfile and commit that (from my local machine to github site) but now my problem is, i have one folder and i need to commit that folder to git hub, can any one of you help m e on this.

Try this :
git add myfolder
git commit -m "some message"
git push

git add FOLDERNAME
After that, you can do a normal commit + push as you did it with the README file.

Its very simple. Follow some steps-
Just click on the Upload files button.
Now you can see a window where you can drag or upload the files.
Just drag your required folder and it will upload in the repository (don't click on the choose your files button, it will upload your files only, not folder. )

Try this :
git commit folder_path -m "your comment"
folder_path should full path, something like this ../../../folder_path

Follow this steps to update your folder to GitHub:
Step 1: Navigate to your local repository(folder) that contains your code and initialize it
$ cd folderName (or) $ cd ~/FolderName
$git init
Step 2: Add the folder to be a part of trackable files/folders list in GitRepository
$ git add FolderName/
step 3: Commit the folder(save your changes made) to GitRepository
$ git commit -m "Some Message"
step 4 : connect GitHub to your local machine, Here you add a remote name origin to GitHub Repository. You can get this URL from "Clone or Download" link from your GitHub
$ git remote add origin URL
Step 5: Push the committed files/folders to HitHub repository
$ git push -u origin master
Refresh the GitHub repository and you could save the folder committed to respository.
I hope this would be helpful!!

Related

Pushing folder into github

I was trying to push the folder on my computer to GitHub. So I created a GitHub repository, and use git bash command line. I didn't push the folder successfully on my first try. Then, I deleted the old GitHub repository and created a new one, and tried using the git bash command line to push code again. However, it shows nothing to commit.
Here is an image to better help understand
According to the image, I understand that you have made a commit but your commit was empty and you did not track any file with git beforehand. You typically want to track the files you want to commit. So in this case you could use git add before committing:
git add .
This should track all files in the current folder after which you could commit and push them:
git commit -m "Some message"
git push
When you create a new repository on git, it shows you how to properly upload data
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/youracc/your.git
git push -u origin main

Github - How to commit my project to a sub-folder / directory of a existing repository?

In Github, i have already a repository, e.g. called "java8"
And under it, i would like to have a sub-folder, e.g. called "01-lambda"
So my folder structure in github should be
java8
01-lambda
02-enums
etc.
Then I want to commit my code to the sub-folder "01-lambda"
How can I do that?
What I tried:
I just created a new folder with a txt file "01-lambda" under the repository "java8", then I tried to commit, but git bash shows they cannot find the sub-file.
I just commit my code directly to repository "java8", but then I need to change path of every files, and add /01-lambda in the path
git init
git add *
git commit -m “my first repo”
git remote add github .git
git remote -v
git push -f github master
I just created a new folder with a txt file "01-lambda" under the repository "java8", then i tried to commit, but git bash shows they cannot find the sub-file.
You need to add before committing, assuming you do have a file inside the new folder (Git would not add just a folder):
git add 01-lambda
git commit -m "add 01-lambda"

Pushing projects to github

I want to upload a project in git hub and push my project in git hub account?
what does this statement mean:
"We recommend every repository include a README, LICENSE, and .gitignore."
Can someone suggest how to proceed after this?
Minimal Set of Steps:
Assuming you are working on some terminal.
1) Clone the project
git clone link-to-your-repo
2) Move inside project directory
cd repo-name
3) Add files
For adding all files use
git add .
4) Commit files
git commit -m "commit-message"
5) Push files to Github
git push -u origin master
6) If you haven't setup SSH keys, it will ask for credentials. Enter your credentials.
Voila!
Github is recommending to include some files, but these are not required to push your project to a repository.
The three files are README.md, a license and a .gitignore file.
The README.md file is what you will see when viewing the repo and it can contain anything, but a good template of what to include can be viewed here.
The license is what specifies how/if the code can be used by other people and any rules that will govern that use.
The gitignore file specifies what files git will ignore from including in the repository. A good description of this file and how to use it can be found here.
These are all optional so after including them/not including them you can just push your code the repository as usual:
git add .
git commit -m "initial commit'
git remote add origin <your repo url here>
git push -u origin master

push my project to github

I followed these steps: https://help.github.com/articles/generating-ssh-keys
now, I want to create a folder in my github account, is called: "TODO_LIST", and push my project into this folder.
what I should do? I'm located in the folder I want to add.
should I need to do something like the next following?
$ git init
$ git add .
$ git commit -m 'first import'
$ git remote add origin git#github.com:alonshmiel/TODO_LIST.git
$ git push origin master
p.s, I have two SSH keys in my account because I push from two computers.
This is explained in the Create a Repo help page:
Every time you make a commit with Git, it is stored in a repository (a.k.a. "repo"). To put your project up on GitHub, you'll need to have a GitHub repository for it to live in.
[...]
Click New Repository.
Fill out the information on this page. When you're done, click "Create Repository."
[...]
git init
# Sets up the necessary Git files
git add README
# Stages your README file, adding it to the list of files to be committed
git commit -m 'first commit'
# Commits your files, adding the message "first commit"
[...]
git remote add origin https://github.com/username/Hello-World.git
# Creates a remote named "origin" pointing at your GitHub repo
git push origin master
# Sends your commits in the "master" branch to GitHub

github uploading project issue

I created a github new repository first in github webpage and then I opened Git Bash to upload folders to this repository. I first used $cd f: and $ git clone git#github.com:username/project name.git to create a folder(with a initial .git folder and a README file in it) in f disk. Then, I used $cd f:\project name to switch to the current folder. After that, I copied all my project folders to my project name folder in f disk. Finally, I used the following four lines to upload all my project folders to github:
$git add .
$git remote rm origin
$git remote add origin git#github.com:username/project name.git
$git push -u origin master
After I entered the passphrase, Git Bash just showed everything up-to-date. But I refreshed my github repository page, there is nothing but the initial README file. Could someone tell me what the matter is?
You didn't commit after your git add.
git commit -m "first commit"
That is why git considered there was nothing to push: you HEAD was still the same than your remote origin cloned repo.
See Git Basics:
Your git add updating the staging area (index), but only a git commit will update your git directory.