How do I pull your last commit from GitHub to C9? - ruby-on-rails

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

Related

How to updated deleted files on Github

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.

Git pull request - how to pull and update Sublime

I've made a stupid error which has messed up my database on a Rails App I'm working on. Luckily I'm on a branch and haven't committed any changes so the version on Git is in working order.
How do I now pull through the Git version and update to Sublime so I can carry on working as if nothing happened?
I've just done git pull origin master but it says up to date so I've obviously done something wrong.
I'm not keen on a db:drop so I'd rather do it this way if possible.
You can't pull again, because you already pulled every commit from your remote.
Add changes, stash them, remove the stash:
git add --all && git stash && git stash drop
This will remove every uncommited change and bring you back to the latest commit on the current branch.
git checkout 01h5y77d (find this in git, a version of the app which works)
This would print "HEAD is now at 01h5y77d..."
You don't have to commit because you did not commit the mistakes yet :)

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.

Git merge conflict with workspace.xml

I'm trying to push my Rails project to Heroku, but Git isn't allowing me to do anything at the moment. Here's what I've done so far:
git push heroku failed because the heroku branch was "ahead" of my local branch, which should not have been possible.
I pulled and there was a conflict with .idea/workspace.xml. I wasn't able to find out what that file is, but it's huge and Git wrote all kinds of garble to it. Too much to manually "resolve" conflicts.
I saw some stackoverflow posts talking about git-ignoring that file (maybe it's some IDE file for RubyMine or something?), so I tried to move the file away to avoid the conflict
I ran git add -A (also tried git add . and git add)
git commit --amend fails because "You are in the middle of a merge"
git merge --abort fails because "Untracked working tree file '.idea/workspace.xml' would be overwritten by merge (despite the fact that the file has been moved)
git reset --merge fails for the same reason.
How can I make Git work again?
.idea/workspace.xml
This file is your idea workspace files. They are generated by IntelliJ tools.
I saw some stackoverflow posts talking about git-ignoring that file (maybe it's some IDE file for RubyMine or something?), so I tried to move the file away to avoid the conflict
Simply add the folder to your .gitignore but since its already committed you will have to remove it from the repository:
# Quit the merge
git merge --abort
# remove the whole folder from the repo
git rm -rf --cached .idea/
# add it to the .gitignore: idea/
# add and commit your changes
git add .- A
git commit -m " Removed idea folder"
git push origin <branch>
If you still unable to do it?
First reset the code to the previous state and then do the above code again.
The reset will take you to your last commit before the pull
git commit -am "message" worked (as opposed to amending a commit)
I have resolved a similar problem by simply deleting the workspace.xml file. By building and running the program again idea will autogenerate a compatible file.

GIT confusion with restKit

So i am learning to ever so slowly use git to get me the latest update of RestKit as the old version has retain cycles...fair enough HOWEVER, when i pull using the gitHub Client it does not give me the AFNetworking files, which i was then told use the command
git submodule update --init --recursive
which i do, problem is that i noticed that after running that i run
git submodule status
It has taken me off the master branch and put the HEAD back in thus reverting me to old stuff. and hence back to leaks and stuff.
So i thought maybe i could install using cocoapods or perhaps put a submodule within the restkit submodule for AFNetworking...all did not seem to work and now i have followed this guide How do I remove a submodule? up until the last step as i dont know what committing will do? i hope it does not commit the fact that i deleted everything onto the restkit site? i am so confused, initially all i wanted to do was switch the current branch submodule i have to the master.
Assistance would be much appreciated.
EDIT:
Okay as to answer what Commit does, commit only affects your copy of the repository and will in no way affect the remote "main" repository everyone else gets their code from, so in essence i was able to commit it, then run a brand new submodule from the branch i wanted, But the question still remains Is there a way to switch the branch you pull your data from when using the update with --recursive?
Simply go in th e RestKit directory and type:
git pull origin master
(if you use the master branch of course)
Also, if you need to update all your submodules, just go to the root of your project, and type:
git submodule foreach git pull
git submodule update is confusing, here what it really does:
When you invoke git submodule update it looks in the parent repository for a SHA for each submodule, goes into those submodules, and checks out the corresponding SHAs.
As would be the case if you checked out a SHA in a regular repository, this puts the submodule into a detached HEAD state.
EDIT
To switch branch of a submodule simply, let say 'development', simply do in the submodule git checkout development and then you should be able to do git pull origin development

Resources