How to update my code from Terminal for Github - c++

Alright, so I have started using Github to easily share my code, and to keep track of updates. My main problem is that I have put my code in my repo, but I am not sure how to update it without saving the updates as a different file, and then pushing that to my repo.
Short version: Is there a way to update my code without pushing a whole new file.

Your question isn't very clear but if I'm understanding you correctly, you can do the following:
Edit the files you need to change
Do git add for each file to make git track the changes i.e. add the files to the staging area.
When you're ready to commit, do git commit to commit the changes. This will commit locally.
When you are ready to push up to github, do a git push. Git is smart about sending up the changes, not whole files.
Git takes a while to understand and it sounds like you're not there yet. I would spend some time going through at least the first few chapters of the Pro Git book, which is available free online at http://progit.org/book/.
Hope this helps.

Related

Can't find the list of commits for one developer on a github repo

I'm using the code from a github repo for my project, and have been trying to understand some of the dev history about a problem I'm having. However, I'm unable to list the commits from one particular developer. Usually, you will see a link option to list all the commits, on the page of any one commit of any given author. But for this one dev only, that link isn't there. Github docs say this could be due to that author no longer having a github account, but that isn't the case here. Also, I can manually append a commits?author=username to the URL, but that doesn't work either. The only way I can see the commits is to load the network graph, scroll the timeline, and mouse-over each commit dot one at a time. It is a difficult way to scan through dozens of commits.
This is best done locally. Clone the repo and then use log or shortlog:
git log --author=author#email.com
or
git shortlog --author=author#email.com
gitk also supports the --author option to filter commits by author.

Django/Heroku After pushing a new version certain templates do not update

I have made some changes to a Django template, saved them, committed them to git, pushed to GitHub and then deployed this new version to Heroku.
The build succeeds and I can view the template but the change is not there.
I checked the GitHub repo, the change is there. When I check the activity feed on Heroku I can see the change when I click the Compare diff link.
When I make changes to other areas of the project, views etc there's no problem, I have updated other templates without issue but can not get the new CSS into the deployed version.
Inspecting the code of the deployed version shows the old CSS not the new so it isn't just an issue with my stylesheet, inheritance or so on.
I've run out of ideas, any suggestions of how I can resolve this?
I have found an answer, it seems a little like using a sledge hammer to crack a nut but ...
Anyway I deleted the templates directory, went through a cycle of commit, push deploy. Reinstated the templates directory redid the commit, push, deploy cycle and for whatever reason the CSS is now being picked up and displayed as expected.
I still have no idea what the original problem was, why it happened or how probable it is I will have the same sort of issues again so any suggestions, explanations and clarifications would still be much appreciated.

Removing Secret Key from Heroku Git Repo

I have taken a project live with the help of Heroku. I set secret keys properly, using environment variables etc, not committing local settings containing any secret keys etc.
Then, reviewing which actual files had been pushed to the git repo within Heroku, I found an 'old_settings'-file which in a pure oversight had been missed. That file contained the secret-key.
I cleaned out the file and pushed the changes to the repo (git push heroku master). Then I deleted all past commits following the last answer:
removing commit history in git
Should this be fine? Reading Mipadis answer so it seems:
Pushing secret keys to heroku, safe?
Should this be a problem, or would this be considered problem solved?
Appreciate any feedback, and should my English be confusing at all I'd be happy to clarify.
Edit
Generated a new secret-key the same way Django does it, and updated the Heroku environment-variable
heroku config:set secret_key=NEWKEY.
Question remains: would this be sufficient?
GitHub states:
Warning: Once you have pushed a commit to GitHub, you should consider any data it contains to be compromised. If you committed a password, change it! If you committed a key, generate a new one.
This article tells you how to make commits with sensitive data unreachable from any branches or tags in your GitHub repository. However, it's important to note that those commits may still be accessible in any clones or forks of your repository, directly via their SHA-1 hashes in cached views on GitHub, and through any pull requests that reference them. You can't do anything about existing clones or forks of your repository, but you can permanently remove cached views and references to the sensitive data in pull requests on GitHub by contacting GitHub Support or GitHub Premium Support.
It would be best to generate a new secret-key just to be sure.

How to clone a Django project without breaking it?

I built a (relatively simple) Django project following a tutorial (the recently released Hello Web App book.) I committed my changes along each step of the way, and I have my working solution in a github repo. However, when I clone the code into a new work space such as onto a new machine or into a new slot on a cloud IDE, the app doesn't work. I get a few errors and with each I resolve, another pops up. Basically, my environment is totally messed up and incompatible with the app beyond having Python and Django both installed.
I realize that I can read through the error messages I get when I invoke runserver, solve each one by one, etc. but it seems there should be a cleaner/simpler way to be able to pull down my repo to a fresh workspace and have it up and running in just a minute or two. I've read recommendations about using virtualenv, but it also seems like people discourage including venv inside your repo because of the extraneous commits and added bulk that will result from it so I don't think that actually solves my problem of trying to reduce new workspace configuration effort.
Perhaps I am overly optimistic, but I'm hoping someone can give me a recommendation to avoid the need to workout these kinks each time I start fresh.

Merging two git repositories together with Django web server, one developer

I started my Django project locally and have been using git just fine.
I got ahead of myself and copied the code to the server which instantly became out of sync with my local version. I hadn't done a branch or anything.
The two part question is what's the best structure for me to work locally, push/pull to test server and then update live server when test is solid, and how do I get it setup from where I'm at?
I've been developing with no branches in these early stages, but I'd like to instead follow standard practices for branching and merging.
I'm using NetBeans 6.8 locally for coding and I've also got GitX. So any integration tips would be helpful also but I'm comfortable doing whatever command lines are necessary.
Thanks!
James
First you should be able to have some form of communication between the git repositories you've got on your local machine, the test server and the live server. Git is very flexible in this regard so a few of the options are:
Have the test and live server pull
from your local repository.
From development push to the test and live servers on appropriate times.
From development push to production and have the test server pull from production.
Have a fourth location where you'll store your git repo and push from development to that repository and have test and live pull from there.
Either way, once you reach a stage where you'll want to try something on the test server, create a tag. On the test server checkout that tag (git checkout <tagname>) and do your testing. (And once you are satisfied that it works the way you want, you can also use that tag on production. But I guess that's pretty obvious. :) )
The intermediate step, between creating the tag and checking it out, completely depends on your setup. Using the fourth option I just mentioned you'll need to push your tag first and fetch it on the testing machine. So the whole process would look similar to this.
<development>$ git tag v1.0
<development>$ git push
<development>$ git push --tags
<testing>$ git fetch --tags
<testing>$ git checkout v1.0
<live>$ git fetch --tags
<live>$ git checkout v1.0
Optionally you can (ab)use git decribe to check which tag you've got checked out at currently.
Regarding the branching and merging: what I like to do is create a branch for every feature I'm working on. Once I complete that feature I merge it back to master. So If I need to release before a feature is done, I can just leave that feature (and every releated) commit out of the release.
But this is just one way of doing it. You can setup the workflow to suit your situation. Especially regarding the use of branches. A more complex setup is described by Vincent Driessen in his article A successful Git branching model.
Disclaimer: I'm using git almost exclusively with one authoritative repo on a server (the fourth option). I haven't personally tried the other setups I suggested...
Update to respond to the comment by iJames:
To make dev push to and test pull from a new/different repository by default from now on, see the accepted answer of this question:
$ git branch --set-upstream master origin/master
With regards to the terminology:
Push is relatively simple: it pushes your local commits to a different repository. See for instance the Git User's Manual.
Fetching does the opposite, it "will update all of the remote-tracking branches to the latest version found in the repository". (Quote from the Git User's Manual.)
The pull command not only fetches the changes in, but also merges them into the current branch. (See the example in the official Git tutorial.)