Skip to content

Git

Untrack files already added to git repository based on .gitignore

Commit all your changes. Before proceeding, make sure all your changes are committed, including your .gitignore file. Remove everything from the repository. To clear your repo, use:

git rm -r --cached .

Re add everything.

git add .

Commit.

git commit -m ".gitignore fix"

Use Gist as Repository

It's probably easiest if you just start by cloning the gist, so that origin (a "remote" that refers to the original repository) is set up for you. Then you can just do git push origin master. For example:

git clone [email protected]:869085.git mygist
cd mygist
# Make your changes...
git add .
git commit -m "Better comments"
git push origin master

However, if you don't want to redo your changes, you can do:

cd mygist
git remote add origin [email protected]:869085.git
git fetch origin
# Push your changes, also setting the upstream for master:
git push -u origin master

Strictly speaking, the git fetch origin and -u argument to git push origin master are optional, but they will helpfully associate the upstream branch master in origin with your local branch master.

Comments