Problems with adding files form git add - github

I have a problem with Github contributions. If I update the file on GitHub with git add Github doesn't show my work in contributions but if I change any file in the browser on Github add my work in contributions. So who have or had this problem???

Have you added, committed, and pushed the change?
The workflow in local repositories is to use
git add <filename> to stage the file.
git commit -m "<Your commit message> (skip -m "message" to open the configured editor).
git push to push your changes to the remote repository.
With steps 1 and 2 you have only modified our local copy (clone) of the repository. To add the local changes to Github, you need to push them. So, the last step will show your changes on Github.
Why the Github form is working:
On Github, you change the file in the form and you enter your commit message below the form. No need to push the changes here as you are already working in the remote repository. It's already live when you confirm your commit message.

Related

How to delete specific commit histories in Github created via file upload?

I normally upload my files to Github repository through the web interface. I accidentally uploaded a file to Github repository recently and this file contains information which I don't want others to see. Now, this private info is permanently recorded in the commit history.
How can I delete this specific commit from Github?
EDIT: The commit history was created through the file upload website of github. It was not created using git.
I will answer my own question. Credit goes to sasha-dev for his comment.
Here is what I did.
Use Github desktop to clone the github repostitory.
Launch command-line prompt. Go to the repository folder. Run the
following command;
git reset --hard HEAD~1 # remove last commit
Or the goal is to remove a specific commit, find out the commit hash
git reset --hard <commit hash>~
Next step is to force push the locally made changes to the remote github repository. Run this command;
git push -f
Commits will be removed from github repository at this point.

Make the current commit the only (initial) commit in a Git repository that was created with GitHub Desktop

I created my first GitHub repository using GitHub Desktop (Windows). It is a real mess with many revisions that are quite meaningless and some versions of files that I would rather were never uploaded. This was the result of a lot of experimenting to get the feel for how things would appear on GitHub. I want to get rid of all the history versions.
I am tempted to just copy my files on my drive to another folder then delete the repository folder from my drive. Also delete it from GitHub.
Then create a new repository with GitHub Desktop, perhaps with the same name or with a different name then rename it to the original. Could it be a simple as that or will GitHub still retain the files somewhere?
I haven't tried this because in my searching I keep finding all the complex steps to be performed to remove histories or remove files.
I sort of feel that what I am proposing is too simple.
Any opinions?
All of this got too confusing.
I just did what I said in the start of the thread.
It seems GitHub Desktop has some Username/Password problem and won't let me "Publish branch".
So I went to GitHub and created a new repository and uploaded all the files from my local folder.
It looks good to me.
There may be problems in the future. I guess I'll cross that bridge when (if) I come to it.
An alternative approach is to switch to command line and:
delete the .git folder in your repository
recreate it (git init .)
reset the origin remote: git remote add origin https://github.com//
Make a first commit with your current content:
git add .
git commit -m "first commit"
overwrite everything on the remote repo
git push --force -u origin master
The end result will be the same repo but with only one commit.
You can then switch back to GitHub Desktop.
From here.
First make sure you have Git for Windows installed, you are going to need to do git commands manually sooner or later.
Go to your local repository on your computer where your project is located. It's a good idea to show hidden files so you can see that you have the .git-folder and that the .gitignore-file is in place.
Go to the folder where the .git-folder is, right-click and click git bash here.
Now enter these commands:
Create Orphan Branch – Create a new orphan branch in git repository. The newly created branch will not show in ‘git branch’ command.
git checkout --orphan temp_branch
Add Files to Branch – Now add all files to newly created branch and commit them using following commands. Don't forget .gitignore!
git add .
git commit -m "the first commit"
Delete master Branch – Now you can delete the master branch from your git repository.
git branch -D master
Rename Current Branch – After deleting the master branch, let’s rename newly created branch name to master.
git branch -m master
Push Changes – You have completed the changes to your local git repository. Finally, push your changes to the remote (Github) repository forcefully.
git push -f origin master
Git overview

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

How to add files to be commited in GitHub

Hello I recently started using github. I was able to make my first commit and upload my Java projects whole source folder to my only Repo. Now I have made changes to my files and would like to recommit the same files but after two hours of tutorials I am still stuck.
This is the process I have been doing.
Windows 8
Gitbash
cd ~\javaProjectSourceFolder(lets call it java)
git init
initializes
git add -A
git status
nothing to commit, working directory clean
I realize I am a newb and that I am not able to "add" my files. Can somebody help me out?
Please make sure you are on the right branch. If not then do the following from the terminal on the repository path. You should do your changes to a local branch, that may be the clone of the master. And next time follow these steps.
git branch :This will list all your branch. You must see master branch over there.
git checkout master : This will make you to switch on the master branch.
git checkout -b local_branch : This will create a branch with local_branch name & then you can add all your code here.
git add -A : this will automatically add the files that are even newly created or modified or deleted.
git commit -m "my commit message : This way you can do a commit to all changes.
git pull origin HEAD : This will update the current branch with any changes (in case of shared repository) You can avoid this as you are the only one working on your only repo.
git push origin HEAD : This will push your changes to the remote branch, but it will not merge this to the master unless you either push it to master or try merging from web on git hub.
For more information on each & every command, please refer the treasure here

Why does nothing happen when I click fork on github?

I created a repository in github and then issued the following command on my local box:
git push origin master
Now I see all of the files on github.
I would like to start work on making changes. With this in mind I clicked the fork button on the
github screen. However nothing happens. I see a message at the bottom of my browser screen but
that's all.
How do I copy my "forked" version to my local computer?
If you want to work on your GitHub repo, you need to clone it locally.
If you want others to contribute directly in your repo, you need to declare them as collaborator.
You could set up a dedicated branch for them to use.
If you don't want them to push directly to your repo, then your colleagues need to fork your repo, and clone their fork locally.
If it's your repository, there's no need to fork the repo.
If I read your question correctly, to make changes, simply edit the files in question in a text editor, save them, open terminal, change directory to the one with the code, and write git add . then git commit -m "Your commit message" and then git push. The new code should be updated in GitHub as a new commit.