Everything Up to Date but really isn't github - github

I git cloned a repo down to my local machine.
I forked that repo to my github account.
I made changes in my local files in sublime
I removed the original repo's origin because I want to push to my now forked repo
and then continue to alter my local files
when I do git diff you see the files I altered
when I do git remote -v I successfully see my forked repo
when I do git push -u origin master I get Everything is up to date but it isn't ...
and when I do git branch I am in my master branch.

You need to git commit, then push the new commit to your remote repository.
git diff compares the files on disk to what git is tracking; git push compares what git is tracking locally to the remote.

Related

Github Simple Commit Issue

I made modifications to my github repo on the actual website rather than the terminal. Now, I can't commit anything locally from my computer to my terminal because it says the files stored locally are not in sync with the github repo. How can I fix this so I can push my changes in terminal? Can I undo my previous commits that I did on the website?
(Optional) If you've some modifications locally, stash them first:
$ git stash
Because you've made some modifications at remote repo, you need to pull them down before pushing new commits (fix conflicts one by one if you got in this step):
$ git pull origin your_branch
Now your local branch & remote branch are in same stage, get back previously stashed modifications back (if you did step #1 before):
$ git stash pop
$ git add .
$ git commit -m "commit msg here"
It's OK to push local modifications to remote then:
$ git push origin your_branch
Btw, if you did modification at remote repo BY MISTAKE, and just want to use local repo as latest, you can push local repo to overwrite remote one (make sure remote repo's branch is not protected by server):
// !!! Use it wisely & carefully, cause it will overwrite the whole branch at remote side.
//
$ git push -f origin your_branch

How to delete GitHub blame history?

I'd like to delete the GitHub blame history that GitHub shows (tracking all changes made)
I am aware of how to how to roll back changes, but I am not trying to roll back any changes I have made, I am simply trying to delete this history of the changes.
Obviously, I do own the repository that I will be operating on (and am the sole owner)
If this is for all files of your GitHub repository, the simplest way would be to:
initialize a new local repository
add files from the original repo
add as remote the original repo GitHub URL
force push
That is:
git clone https://github.com/me/myrepo
git init myrepo2
cd repo2
git --work-tree=../myrepo add .
git checkout # -- .
git commit -m "Import myrepo"
git remote add origin https://github.com/me/myrepo
git push --force -u origin master

Remote repo says it is up-to-date, but lacks hundreds of local commits

In Eclipse (using Egit) I have my repo set up like this:
I pull from a remote GitHub repo (my lecturer's) at github.com/hallvard/tdt4100-2017
I add files and modify a few of the ones I pull from there. Using Eclipse's egit, I commit changes to my local repo (including all files from the remote pull repo.), and push everything to my own GitHub repo where I then have all of my own files, and my lecturer's files, and my lecturer's modified files.
That repo is at github.com/vegarab/tdt4100
Yesterday something weird happened: When pushing to my own repo., it kept saying the master branch was up-to-date, which it was NOT.
YES I did stage the files, and they were commited to the local repo.
I tried going to terminal and pushing to remote from there, but no luck.
I headed to my GitHub history and found the last commit, and did a:
git reset commitid
I then tried to push to the remote, but it still said it was up-to-date? EH WHAT?
I copied my local repo just to make sure I still had my files if something went wrong:
I did a
git pull -f origin master
and it did some changes: My my remote repo is just a fork of the lecturer's repo. All my files are gone, except they are still there in the local repo. Trying to push them gives yet another up-to-date, except the remote now misses hunders of my own commits, and hundreds of files and folders.
What do???
Make sure you are Pushing to correct repo. Say you have two remote:
upstream: The repo from where you forked your own repository
origin: Your own repository
Clone your own (origin) repo.
$ git clone <own-repo-url>
Do changes, update files, Add, Commit, Push to origin
# do some changes
$ git add .
$ git commit -m 'Add my changes'
$ git push -u origin master
Now assume upstream is updated and you need to take the upstream's new changes and then update own origin repo.
$ git pull upstream master # pull upstream/master changes
$ git push origin master # push the changes to origin/master
I ended up pushing the local backup repo. to the remote one, which "restored" the remote one into the correct state.
I then deleted the original local repo, and created a new one, pulling from my remote repo. I then pulled new changes from lecturer and pushed to my own repo. It is now fixed.

Unable to find branch in git repo

In the current directory. I had made a repository yesterday from this directory.
now:
git branch foo
After doing some changes in the file..
git add .
git commit -m "commit1"
git push.
I am unable to see the branch from my repo on github. While git branch does show this foo.
What you did is creating a local branch;
you will need alternatively to make it a remote branch:
git push <remote-name> <branch-name>
where <remote-name> is usually origin

How do I commit a new project version on GitHub?

I'm new to GitHub and its terms confuse me a little. I made a commit. Now I want to change the project to a new refactored version.
Do I need to delete files from the existing repo before commiting new version (if the structure was changed and some of the files are not needed anymore)?
Do I need to push or to commit? Or do I need to do something else?
Making a commit updates the repo on your local machine. Doing a push will replicate your repo changes on a remote.
You can commit as many times as you want locally. Once you are happy with the state of your repo, you can update the repo on Github with the following command:
git push origin master
If you want to delete a file from the repo, you can do this:
# remove the file
git rm path/to/my_file
# commit the remove to your local repo
git commit -m "removing my_file"
# update the remote (Github) repo with the removed file
git push origin master
If the repo doesn't exist on Github yet, go ahead and create a repo there. They will give you step-by-step instructions on how to make your first commit. It will likely look something like this:
# go to project files
cd path/to/project
# initialize git repo
git init
# stage all project files in current directory to be committed
git add .
# make first commit
git commit -m "first commit"
# add the Github remote
git remote add origin <YOUR GITHUB URL>
# send repo to git
git push origin master
a commit to github is in two steps:
->first use command commit to save the changes localy
->then use push commande to save the changes on github