How to updated deleted files on Github - ruby-on-rails

I'm working on a project in Rails and was using a CSS framework that came with some images. I later decided to use something else and no longer need the images. I deleted them, committed my changes to github but now every time I I commit to github it pulls the files I already deleted. How do I keep it from doing that? I want those changes gone for good, not readded to my project every time I merge.

After committed have you push your change to repository. Please do following
delete images
git status
You will see files changed are comming in status, if images comming than go head and continue, you can either run git add . to add all files or
git add images_name_or_folder
git commit -m "Removed images"
git push
Now check and do `git pull` to check if all images gone.

I fixed this by doing a force push. I don't understand the problem but I forcing the push fixed it.

Related

Accidentally committed and pushed 'database.yml' to Rails Git Repo

I am working on a Rails project!
Excuse for not adding .gitignore
I have accidentally committed and pushed 'database.yml' in to my feature branch. A pull request was created from the feature branch to master branch a few days ago and is not yet merged. There are multiple commits done as part of this pull request and the commit containing 'database.yml' is the fourth last commit.
Others are also working as part of this project and they are merging the changes to master and we are pulling those changes in to our feature branch in-between. Thus, in our feature branch, we have got commits from others which are done after the faulty commit.
so I wish to do a 'git rm' and 'git push' the same file again to resolve this issue (as the PR is not yet merged). Will that create problem?
If you remove the database.yml that will be another commit on top, and nobody will be affected.
Notice, however, that the database.yml will still be part of the history and can be accessed via git log. If that file contains sensitive information, it will be findable by others.
Delete the file from your local system then add the changes to a commit using
git add <FILE_PATH> command and then commit and push the changes and it should be fine.
The right way to remove it properly is to reverse the changes you made to the file and commit it.
Another, dirtier way, is to open the commit and remove the changes and force push it to the repo. But you need the proper rights for this. Others will also have problems if they try to pull changes then.

How do I pull your last commit from GitHub to C9?

So, I kind of messed up and went and deleted all my files on C9. I haven't saved anything yet, so I'd like to pull my last commit into my C9. I read somethings that said I should download the zip file of the commit, but I don't really know what to do with that. If anyone could help me I would really appreciate it!
If you guys need any more info, I want to pull from my last commit because I deleted all my branches except my master branch and all the hidden files that I might need later. I couldn't really find anything about pulling into C9 from Github so I thought this would be a good question to ask you guys.
you can delete all the files that you do not need then run the following
cd ~/workspace # make sure you are in the right folder
git init . # create new git repo instead of the one you've deleted
# now add your github repository as origin
git remote add origin git#github.com:jinntakk/upskill_saas_tutorial.git -f
git remote set-head origin -a
git fetch # fetch your commits from github
git reset origin/HEAD --hard # reset working tree to the remote

problems with pulling or pushing the code

My question is very basic but still it is unclear for me. I am working on a rails project with multiple developers. All of them can pull or push the project. So let me explain my scenario. If I am making changes in my code for the first time and the other developers are also making changes, when I try to push the project I am able to do so. But the other developer face problem in pulling the project. After that If they are able to make changes and pull the project then I am unable to push the project or pull the project. This is how we push the project first:
git add .
git commit .
git pull origin master
but the error comes warning: Cannot merge binary files or I get the error git pull fails with “Untracked working tree file 'blah' would be overwritten by merge
The problem is coming because you and your friend doing changes on the same line of the file and git is unable to decide which one to take. So in this case its better to go for stash first to save your code.
The code will be:-
git stash :- To save your code
git pull :- To pull the code from git
git stash apply :- To merge your changes with the pulled files, if any merging error is coming then it will hit an error saying merge-conflict,you have to resolve that manually.
git add :- To add the files
git commit -m "Commit message" :- To commit it
git push :- To push to the repo.
I think this will solve your problem
git checkout accepts --ours or --theirs options for cases like this. So if you have a merge conflict, and you know you just want the file from the branch you are merging in, you can do:
$ git checkout --theirs -- path/to/conflicted-file.txt
to use that version of the file. Likewise, if you know you want your version (not the one being merged in) you can use
$ git checkout --ours -- path/to/conflicted-file.txt
ref:Resolving a Git conflict with binary files
In your case the file is 'blah' in the working directory of remote location. so u can keep one of them.

Moved my bundle directory, so now it get's included in my GIT. Is there a wat to remove?

I moved my bundle directory for my ruby gems, but forgot to add the new directory to the .gitignore. So now my GIT is trying to push all the gems as well. I googled around, but I can't find a way to reset my GIT or remove the new bundle directory from the index.
Any ideas?
You can back them up(ie. move them out), get your gitignore adjusted, do a commit with this .gitignore and removals, then put them back after, then push.
So like this
let git commit them (not push them) (suspect you already did this part, which is why your saying they are tied in now)
move them out of your project file, and adjust your ignore file now
mv new/gems some/ignored
vim .gitignore
git add. those changes which will set them for removal
git add .
git commit which will delete them out of the repo (that which will be pushed)
git commit -m "quick removal of supposed ignored gems"
now move your files gems back into their new ignored place
mv some/ignored/gems new/
git status
you shouldn't see them listed anymore. now its safe to do your push
git push
Your mistake will become part of history, as well it should, to get you into the proper habit of keeping commits, and not rebasing. Then you will see exactly what you did, and be able to back track easier. Erasing mistakes can be costly, its best to just let the commit be if its a mistake, and add another commit to fix. If pushing is involved this all can be done before pushing.
Dont push until its well and ready. spot qa test it after making adjustments one last time is a good habit just before pushing. That gives you one last time to correct any mistakes you missed before release.
So never hesitate to commit, commit, commit! Commit frequently, at logical breakpoints, and note your changelog briefs in bullets (hyphens) as comment -m "new release of blah blah, - problem 1 fixed - problem 2 fixed - etc.." on each commit

github is not the same after push

I'm wondering how this is possible.
I made quite a bit of changes to my rails project (deleted some stuff, edited files, added files, ...) as I implemented a whole new design.
And now I want to commit my project and push it to github
git merge new-view
git add .
git commit -am "implemented the new design"
git push origin master
Now when I pulled the changes on another computer I noticed that not all of my features were working. (for example the image slider wasn't functioning).
When I go trough the files, it looks like all the changes I made are there, but I must be missing something because both projects are not behaving in the same way!
Even when I clone the project again from github (on the original computer with the working projectfolder), the feature still doesn't work.
git clone projectname
Now in my old folder I can't push any other changes as status tells me that my branch is up to date with origin/master
git status
I figure that I can just delete the github project and upload it again, but that's obviously not the way this is supposed to be done.
Any ideas what could've gone wrong?
Make sure that no important files are being ignored- see this answer
Make sure everything is truly committed. git status and git status --cached
Make sure any databases are initialized, migrated and populated with the same data.
Check browser caching.

Resources