Pushing projects to github - 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

Related

How to upload folders on GitHub

How can I upload folders to GitHub? I have all of my code in a folder, containing 98 files, on my desktop. I know how to upload files, but it there a way to upload the entire folder?
Thanks!
This is Web GUI of a GitHub repository:
Drag and drop your folder to the above area. When you upload too much folder/files, GitHub will notice you:
Yowza, that’s a lot of files. Try again with fewer than 100 files.
and add commit message
And press button Commit changes is the last step.
You can also use the command line, Change directory where your folder is located then type the following :
git init
git add <folder1> <folder2> <etc.>
git commit -m "Your message about the commit"
git remote add origin https://github.com/yourUsername/yourRepository.git
git push -u origin master
git push origin master
I Understand where you are coming from.
The solution provided by #James Graham may not work in certain cases. The Drag and Drop Functionality may cease to exist. See below link when that happens:
https://www.reddit.com/r/github/comments/meuxtg/github_drag_and_drop_not_working/
If somebody wants to avoid the shell and all the commands and wants to have a UI to do that,Github Desktop is one of the way to go forward.
Steps to follow to install and use Github Desktop:
I am assuming you know the difference between local repo and remote repo
Install Github Desktop
Create a repository locally on your hard drive by using github desktop. This will automatically create files like .git and .gitattributes. It also asks to create a README.md file, always best practice is to create it and edit it informing readers about your project overview, installation steps etc. README.md is rendered in Markdown and can also render HTML. See more about Markdown here: Markdown Cheatsheet guide
Copy and Paste all the folders and files that you want to upload(basically the right terminology is "Push" ) into this newly created local repository. Be aware of the directory structure as the exact same directory structure will be replicated on your remote repository.
Go to github desktop, as soon as you paste files in the local repo, you will see them as changes here. All you need to do is commit these changes with a comment. This will be your "First or Initial Commit" to the repo.
Next Github repo will ask whether you want to publish these to its remote repository. Click "Publish" Note Publish is just a one time operations. Going forward any further changes you make to local repo will be seen in github desktop and you need to again follow the loop of "Commit local->Fetch from remote->Push to Remote. As long as you are the only developer working on a project you need not go into other mechanics of git branches etc.
To verify if your repo is published remotely login to your github profile on the web and see your repository sitting there. This your remote repo which you effectively created from your local repo by using Github desktop.
I've just gone through that process again. Always end up cloning the repo locally, upload the folder I want to have in that repo to that cloned location, commit the changes and then push it.
Note that if you're dealing with large files, you'll need to consider using something like Git LFS.
For those still using master, this was changed to main
echo "# repo-name" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/username/repo-name.git
git push -u origin main

Does github honour Jekyll's "source" variable?

In an attempt to make my workflow a bit neater, I came across the source tag, which allows me to host my "dev work" in a separate folder than my _site.
This is awesome, but it does not appear to be honoured by Github pages? I feel like I am doing something wrong though, so just wanted to check. I couldn't find much about it online.
In this case, I don't explicitly need github to do it, but it would be great to have this consistent workflow for projects that do rely on github pages.
Thanks!
GH Pages overrides the source setting in the Jekyll config file:
https://help.github.com/articles/troubleshooting-github-pages-build-failures#source-setting
http://jekyllrb.com/docs/github-pages/#project-pages
You don't need to change source or destination parameters to version them separately. You can just version them in two different branches from the same repository.
Why versioning in different branches ?
If you need some plugins (generator, tag, ...) or build tasks (gulp, grunt, ...) that will not run on gh-pages, you will have to publish your Jekyll sources in a branch and your build results in a separate branch.
For a User / Organization site, it will be master for the site build, and sources (or any name you like) for the code. A User / Organization site will be versioned at github.com/userName/userName.github.io and hosted at http://userName.github.io (or with a custom domain)
For a Project site, it will be gh-pages for the site build, and master (or any name you like) for the code.
A Project site will be versioned at github.com/userName/projectName and hosted at http://userName.github.io/projectName.
Steps for User\Organization site
create a repository on github (eg: https://github.com/userName/userName.github.io)
go to command line and cd pathTo/yourJekyllSource
git init
git remote add origin git#github.com:userName/userName.github.io.git
jekyll new . creates your code base
in _config.yml, set the baseurl parameter to baseurl: ''
in .gitignore add _site, it will be versioned in the gh-pages branch
jekyll build will create the _site destination folder and build site into it.
git checkout -b sources
git add -A && git commit -m "jekyll base sources" commit your source code
git push origin sources push your sources in the sources branch
cd _site
touch .nojekyll, this file tells gh-pages that there is no need to process files
git init
git remote add origin git#github.com:userName/userName.github.io.git
git checkout master
git add -A && git commit -m "jekyll first build" commit your site code
git push origin master
And your good to go !
Your deploy can be made like this :
cd pathTo/yourJekyllSource
jekyll build
git add -A
git commit -m "your commit message"
cd _site
git add -A
git commit -m "your commit message"
Steps for a Project site are described here and I've made an automation Rakefile, it can do everything for you from setup to deploy.
Enjoy !

How to push code to root of git repository (GitHub)

I am very new to git and have been facing the problem below for 4-5 days now.
I have a project that I want to share on GitHub and I created a repo (https://github.com/jitix/cfs/tree/master/cfs) for the same.
Here is what I did:
Checked out the code from svn using Eclipse (Juno).
Removed svn related files and 'cleaned' the folder by doing Team > Disconnect.
Created a local git repository (using both via eclipse and cli on different occasions).
Added appropriate .gitignore file.
Committed the code into the local repo (somehow eclipse moves the folder there, but not an issue). Eclipse made me choose the $repo/cfs as the folder where the code is committed. I could not commit it to $repo.
Now I want to push it into GitHub. Tried out the following:
Method 1 (eclipse):
Team > Remote > Push
Use refs/heads/master as both source ref and dest ref and commit.
Method 2 (cli from the $repo/cfs directory):
git remote add origin jitix#https://github.com/jitix/cfs.git
git push -u origin master
Issue:
In both cases, I am getting the cfs directory under the GitHub repo, not at the root (as most projects have). Also, each folder has a .. link to the parent folder in it (something that I have never seen on GitHub, and something that does not happen if I push using svn).
I checked out my code from svn, created a local repo and committed the code into
You need to create the git repository inside the folder that you want to upload. You've created it one level above the cfs folder and then pushed that, you want to run git init while inside cfs and then go from there.
Try in commandline instead using eclipse and follow the steps that GitHub recommends.
Go inside the directory of your project and type:
git init
git commit -a -m "first commit"
git remote add origin jitix#https://github.com/jitix/cfs.git
git push -u origin master
It should work, although is pretty much what you were doing.

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.