Reputation: 169
I have recently cloned another repository. When I open Git GUI, I see a list of files in the "Unstaged changes" top left section. These are mostly css, html, .class, gif, and xml files. And, some java files that I had changed.
Couple of questions:
How do I prevent these configuration and html files from appearing in my list of unstaged changes files? Because of this long list of files, I find it hard to do other operations like "Revert changes" on individual files. Note that this didn't happen when I cloned a different repository in the past. Do I need a .gitignore file?
When I try to pull the latest changes from the repository using git pull
I get the message "Your local changes to ... would be overwritten". In this scenario, is it better to commit my changes first or just revert the changes and pull and then add back the old changes?
Upvotes: 0
Views: 67
Reputation: 66208
Do I need a .gitignore file?
That would take care of the problem of untracked files being listed.
e.g.
git status
# On branch master
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# foo.bar
# foo.html
echo "*.html" > .gitignore
git status
# On branch master
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# foo.bar
is it better to commit my changes first or just revert the changes and pull and then add back the old changes?
If you intend to commit them at some point - clean up the code changes and commit them otherwise/OR you can use git stash to temporarily store your changes and reapply them later e.g.:
hack
hack
hack
git stash
git pull
...
git stash pop # <- restore stashed changes
Upvotes: 1
Reputation: 18550
Use git stash
http://git-scm.com/book/en/Git-Tools-Stashing
That allows you to keep both
Upvotes: 0