GitHub Desktop doesnt pick and push the entire repository - github

I am using GitHub desktop application on my local machine and when I create and complete my repository(web directory)on my local machine, then I push it GitHub online through desktop application. But here is my problem:
Sometimes it doesn't pick and push all of the files/folders from my local repository, it only pick 3 files, while my repository has 5 folders and one inex.html file.
And sometimes it works perfectly fine. I never understand where is my problem. Any thoughts on this?

Do a git status before your push, as well as a git show HEAD to check the content of your last commit.
That way, you will see if there remain some files not added to the index or not committed.
And you will see if every files you wanted is in a commit.
If one file is consistently ignored, see if it is actually ignored by Git with:
git check-ignored -v -- a/file

Related

Accidently deleted every file in Vs Code while trying to push to git, any way to recover them?

I am a complete noob so while trying to deploy one of my programs to heroku, I needed to push it to github, in Vscode while trying to do that, I got a whole bunch of files that I didn't want to upload on github, so I hit remove all from this screen
I now realize that I deleted everything and I don't know what I can do, I tried going into my drive and hitting properties to try and restore but looks like I hadn't turned that feature on. Is there anyway I can recover my files? I am on windows
Simply go to your terminal and navigate to the folder you are pushing to git. You can run these commands:
git log --pretty=oneline (Shows all previous commits)
git checkout . (This resets everything to the previous commit)
Once you have reset your project to the previous commit, try again and delete the files you wanted to remove. Then perform the git commit -am "text here" and git push heroku master commands.
EDIT: This only works if you have already made git commits. If you have deleted everything and git log --pretty=oneline does not show any commits, then there is no way to recover the deleted files.
You can also check the recycle bin of your computer to see if the deleted files are there.

How to view file changes before pulling through GitHub on RStudio?

I'm transitioning from using Subversion in Eclipse for code management to GitHub in RStudio. It's starting to make sense, but I can't seem to figure out how to pull effectively.
Specifically, if I use the Pull arrow in RStudio, every file change in the repository automatically updates my local files without warning. I can see how many files were updated, but not what changed!
Here are the questions I'm hoping to get help with:
1) Can I preview the repository file changes in RStudio before I pull them locally? With SVN in Eclipse, there was an indicator showing files with a difference, and the option to view side by side.
2) If multiple files have been changed on the repository, is it possible to pull just 1 locally?
3) How can I revert a local file to a previous version?
Right now I've been trying to do this all within RStudio for simplicity. I haven't used things like the GitHub desktop client.
I appreciate the help!
I would suggest you better get used to the git's own tools to stay informed about your repository.
For example you could do following.
Before you pull, check your current commit logs
git log
This should show you how your current commits stack up. Note the latest commit id (first 4-5 letters would usually do)
Now after pulling you can see the difference using following command
git diff --color your_previous_commit_id..HEAD
If you don't like the changes and want to go back,
you can just reset to your favorite commit with following command. BTW run "git stash save" to keep a copy of your uncommitted changes.
git reset --hard you_favorite_commit_id
Note: that this will delete all your uncommitted changes unless you stashed them and put your local branch behind the remote repo branch you are tracking again.
Wondering where to put these commands? Check https://git-scm.com/downloads.
What's good about using these git tools is that if you switch between IDEs you don't need to search for same functionalities you had in your earlier IDEs.

How can I copy an git repository in Xcode to github?

Every time a try to use github I get tangled in a series of errors that seem to have no solution and I give up. This time I thought I'd try to get help.
I have a local repository created and managed with Xcode. All the local git functions in Xcode work with no problem. Now I want to put this project on github so others can see it. I logged into github and created a repository. It's this one:
lummis/CS193P-2015-Assignment-5
I added a .gitignore file but then deleted it again because I thought it was causing an error. I tried adding a readme file but wasn't able to. I got some error that didn't make sense to me so I gave up on that. So at this point the github repository is empty so far as I can tell.
My local repository has many commits and is currently up-to-date. IOW there is nothing to commit. But when I do "Source Code / Push" I get the following error:
Working copy out of date. Try pulling from the remote to get the
latest changes then push again.
So I try to do that in Xcode by doing "Source Control / Pull". But then I get this error:
"github/master" is not a valid remote branch to pull from. Please
choose a different remote branch.
But there is only one branch. There is no other branch (local or remote) to choose. So I'm stuck in a Xcode-github error loop again. I searched for information about this but didn't find anything relevant. I have the Pro Git book and read and understood it at least thru chapter 2. But that doesn't help on interacting with Xcode.
Can anybody say what I need to do? I thought of deleting the remote repository and starting over but apparently there's no way to do that either!
I know lots of people use github so it must work once you know how to use it but it's a big source of frustration for me.
You have a local repository with "many commits". Let's imagine that we have three:
A---B---C
^
master
Your remote repository on GitHub also contains commits, but they are different ones from what you have locally, e.g.
Y---Z
^
master
At least one of these remote commits was created through the GitHub web interface, which creates a new commit each time you use it.
Because the two repositories contain no common history, Git can't figure out how to handle a push from your local repository to the remote one. It will refuse to accept such a push rather than making any remote commits inaccessible, which is what you usually want.
In this case, commits Y and Z in the remote repository can be discarded. They simply add and then remove a .gitignore file, and you want the remote to reflect what you have locally. The solution is to force push.
Force pushing should generally be avoided, since it can cause commits to be discarded (like Y and Z will be in this case) or to have their hashes changed, which causes major problems with shared repositories. In this instance I don't see any danger in force pushing, which can be accomplished with the -f or --force argument to git push.
(There's nothing fundamentally wrong with force pushing, and in some situations it makes perfect sense, but it should be done with care for the reasons listed above.)

Git push remote work but no changes visible

I am currently facing a little problem with git when pushing to my remote server.
Everything works fine on local server, it commit successfully and so do push to my remote repo. Git show master and git show remote-repo/master show the commits modifications done so everything should normally work.
Still when accessing my website nothing has changed. The files simply haven't changed. The remote repo is a bare one, my app is built with Flask, Gunicorn and I use supervisor to manage it. I tried to change git remote path to a new directory created with copy of my files in it, restart supervisor and gunicorn, restart my server, but nothing changed. What is strange is that first push worked. I'd net on a problem of directory structure or oath, still everything is the same. Except that my files are stores in one more directory than local. But i tried to copy files in the upper directory and it did not change anything.
I am kinda lost now and would be grateful for decades for any help or clues about this problem.
Thanks !!
Still a little confused on your set up. You develop on local and push to a server. Does the server have the bare repo or does the server hosting the website have the bare repo?
When you push to a bare that doesn't mean the working tree has changed since bare is just a bare repo- no working tree. If this is the case you have to follow these steps:
1. push from local to server that contains bare
2. pull from the remote bare location from the production server
(the one that contains the website)
3. restart apache or whatever you have
Hope this helps. Please let me know if I am on the right track.
Ok so i've got it working finally ! To do so i init another --bare repo and created a folder for website files. Then, in the bare repo, add to /hooks folder a post-receive SH/script file to check-out files when push received from bare directory to the one for website files. I edited supervisor conf and nginx one, reloaded and restarted all. it's okay now !

Git reset gives me "still trying to merge"

I've googled this in many different ways and can't find anyone else talking about it (at least as far as I understand).
On my office pc I was trying to find a solution to a problem I was having (so I was ahead of my remote git repo, but without committing).
That night at home I figured out the solution and pushed it to my remote repo from my home pc.
Now I'm back in work and I wanted to reset my local repo on my office pc to match the remote (and discard all my local changes).
I ran:
git reset --hard origin/branch1
I got:
HEAD is now at 1501f25 **Still trying to merge**
What does this mean?
'Still trying to merge' seems to indicate it didn't complete somehow, but I can't see how (and I'm having no luck finding a clear answer in the git docs).
If a git merge --abort (git1.7.4+, January 2011) doesn't do it, check if you still have a .git/MERGE_HEAD file (and delete it).
Then the git reset should proceed (or, since it completed, the git repo state should be coherent).
Make sure you are in the right branch you wanted to reset to origin/branch1.
As the OP Roy Collings suggests, recloning should get rid of the warning, but that means having one's project config files versioned in order to minimize the time spent to configure everything again in a new cloned repo.
Since relative paths are supported in an Eclipse config, having .project and .classpath in a git repo is possible.