github files not the same as latest commit? - github

I am having trouble understanding/ updating one of my git repos. There is one branch, master. I created the repo on github. Cloned and made edits in Windows, commited, pushed. Cloned in Mac, made edits, committed, and pushed. A few days later made commits from Windows again. Now Github shows my latest commit different code than the files do. Shouldn't github files be synced to the latest commit?
On my Windows machine the repo matches the commit changes shown in the latest commit. (The commit hash link in upper right of github.)
This is different from the repo and on my Mac, which matches the Raw file.
Why does the commit hash show a file with changes, while clicking the file link show the file before the changes? (seems to be root of problem)
How can the files be different than the most current commit?
The repo in question:
The file:
https://github.com/dval/HWiNFO64-Crunch/blob/master/HWiNFO64%20parsing.R
The hash:
https://github.com/dval/HWiNFO64-Crunch/commit/57c44c441ee0d2b39fa5248eaf44b10a3658a023

Related

How do I merge a old changes into a Git repo?

I know this is a common question, but I can't find the answer I'm looking for.
I have a GitHub repository that receive a few bug fixes that I merged into master.
But I have 100s of change in a local folder, and I want to merge the changes with the master.
What I am confused about is where do I start:
Do I create a branch, then drop my new files into that branch folder on my hard drive, commit the changes to this branch, then merge the branches?
If you are the owner of the GitHub repository and have its latest master already cloned, you could simply:
copy over those changes in your local cloned repository folder
git add/commit and push (no merge needed, since you are the owner)
Not that there is no "branch folder": the folder would be the same as your local cloned repository folder.
You can, if you want, make a branch for those changes, in order at least to add/commit those 100s of changes in smaller commits, helping to build a coherent history (instead of one commit, with as commmit message "giant dump of change").
But that would be in the same folder as your currently cloned repository.

How to merge local folder and its structure to github?

I am still a beginner and I locally made a folder of my Project and uploaded it as a repository in GitHub using GitHubDesktop. Now I changed the structure of the files (deleted some sub-folders and moved files here and there locally). Now I don't see those changes in my GitHubDesktopas something which I can push to the GitHub online and reflect the changes there.
I am not sure how to achieve that:
(One way I can think is to reclone and download the online GitHub repository to local, move the changed files again and then commit from GitHubDesktop) , but I am not sure if it will work because I did the almost the same thing just without recloning: but after the reorganization, the changes are not appearing in my GitHubDekstop which I can commit.
Any advice would be great. Thank you.
This is my repository (https://github.com/grammilo/Codes) whose organization I want to copy from a local folder which goes by the same name and was previously cloned from it.
When you go to the directory of the repository in your terminal, checkout your master branch
git checkout master
and use
git diff
this will display any changes made to the files and file structure in green and red. You can delete folders and files directly from your file system or from the terminal, whichever you prefer and these changes will display when you use git diff. After your changes are made use
git add
this will stage your changes to be committed. You can use
git status
to make sure your changes are ones you would like to make.
Use
git pull
to pull any changes from your repository and when you are ready to commit your changes simply use
git push origin master
this will commit your changes to the remote repository on GitHub from your command line without using GitHub Desktop. Check out the git documentation for more in depth explanations but that should achieve what you're looking for.

Git why newly checked remote branch has changed files?

I am new to Git. I have checked new remote branch at my local. As I am checking out a new fresh branch from remote, I don't expect any local changes in the files of my repository.
But somehow few files show changes. I am using Git on Eclipse IDE.
Why is so? Have I misunderstood the concept of new fresh branch checkout?
Update
Based on comments by Tim Biegeleisen and Sajib Khan my understanding was wrong as it is expected behaviour when you check-out remote as a local branch any previous uncommitted changes in the working directory ( Repository ) will carry to the newly checked-out local branch.
Just to put in simple words let me explain with example
Think that your working in master branch and add some new file (Eg file1.txt and file2.txt). Now you don't stage or commit these 2 files then it will be shown as untracked files.
Master Branch
Untracked files
file1.txt
file2.txt
At this particular point of time you switch to another branch then the files which were untracked will be shown in the newly checkout branch.
To over come this problem you can go for the following 2 ways
Stash the files from master branch and then switch to another branch, now it wont show the untracked files of master in newly switched branches. Stashing is nothing but saving the files and then reusing those at later point of time.
commit amending

How to recover replaced files in local Git repository after pull request?

Originally on my Github are some outdated styles.css and JavaScript files and others.
I was working on my project last night but didn't push it to Github or back it up. It was just saved in my local repository using a series of local, unpushed commits.
Being a newbie that I am, I did a git pull request master, and all the files in my local repository got replaced with the original styles.css and JavaScript that was in my github.
Is there a way to get those files back?
I did a git reset head#{2} where I believe the state of the repository before the pull request was, and it showed some unstaged files.
In Gitshell my command line has "master [+10 ~19 -42 !]" with the text master being yellow.
At this point, what do I do? Currently I seem to have lost a lot of work.
If you have performed commits often you can pretty much get to any of them.
Use git reflog first (https://git-scm.com/docs/git-reflog). It will show you all the interim commits you've made. Once you find a relevant one you can do git reset #commit_id.

Git completely replaced changes in history. How to restore files?

I have git repository on bitbucket. I use it from Eclipse for a while, but then copy Eclipse project with local git repository to another place on the filesystem and work locally for 3 weeks. I'm a newbie with git, so I just copy the project as is.
Yesterday I try to push local changes and then switch to the remote branch. Now I see in git-gui only old bitbucket commits and no new files. I search in git-gui everywhere. But the size of the repository tells me that my new files are still there (on bitbucket 16mb, locally >300mb).
git branch shows me 2 branches (master and * (no branch)) and both have bitbucket commits. I didn't make any branches, I just first cloned the repo from bitbucket, then made commits, then made some actions trying to push the copied repo and then change branch. Any idea of how can I restore my local files will be greatly appreciated!
I'm really having a hard time understanding what the exact situation is.
However, if you say all the files are still in the local repo, a simple:
git reflog
is all you need to see recent commits on all branches. Find the right commit you want to go back to, and take it from there.