Skip to content

Instantly share code, notes, and snippets.

@ee08b397
Last active November 5, 2015 02:20
Show Gist options
  • Save ee08b397/f76a495595333daee7d2 to your computer and use it in GitHub Desktop.
Save ee08b397/f76a495595333daee7d2 to your computer and use it in GitHub Desktop.
What should be added and what shouldn't

Why I cannot push?

Sometimes when you want to fork a branch and push your exisiting work, github rejects your push (sometimes caused by being offline). git st looks fine.

When I tried to push, it showed this:
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://github.com/something.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

Though not recommended, this is because there's something in this repo/branch that's not found in local git, e.g., README or .gitignore. So as indicated, git pull REPO BRANCH solves the problem (git remote to check your repo name and branch name). What I recommend is clone the repo to local and start working from here. Github put a clone command right next to the repo on the right for a reason :)

How can get rid of the anonying .pyc files?

Repo should only have source code, excluding

  • complied assemblies .pyc files,
  • log,
  • output files such as pdf or png (for homework grading purposes, this rule may not be followed).

Everytime you run your code, these files are generated and they're not supposed to be checked in, especially you've get used to git add * or git add -a. rm *.pyc is fine for a simple program, but when it's structured in several levels, it's fine by link

git rm --cached *.pyc

Or

find . -name "*.pyc" -exec git rm -f {} \;

There's a one stop shop by setting a .gitignore. Basically it would let git remember to exclude specific files. Adding a .gitignore file in the root of your repo and enter a line: *.pyc

Safely get away from .pyc trouble. A sample Python.gitignore in here

Resource

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment