AI Hints
Home›Git & GitHub Tutorial›Interview Questions 3
Git & GitHub · Lesson 138 of 144

Interview Questions: Remotes and Ignoring

Origin, upstream and .gitignore.

⏱ 2 min read▶ Video at 2:31:12🎓 Free
Watch this lesson in the Git & GitHub courseWatch on YouTube ↗Full Git & GitHub course

Two more classics, about remotes, and about ignoring files.

Interview Questions: Remotes and Ignoring
From the video: Interview Questions: Remotes and Ignoring
  • Remotes
  • Ignoring files
  • Two classics

Origin versus upstream?

Question fifteen. What's the difference between origin and upstream? They're just remote names, by convention. Origin is the repository you cloned from, usually your fork. Upstream is the original project you forked. You push to origin, and fetch from upstream to stay in sync.

origin

  • Where you cloned from
  • Usually your fork
  • You push here

upstream

  • The original project
  • Owned by someone else
  • You fetch from here

Why is my .gitignore not working?

Question sixteen. Why isn't my dot git ignore working? Almost always, because the file was already committed before you added the rule. Ignore rules only apply to untracked files. Fix it with git r m dash dash cached, then commit.

Rule addedafter committing
Ignore applies tountracked files only
Fixgit rm --cached <file>
Thencommit

Summary

Origin is your copy, upstream is the original. And ignore rules don't apply to files already tracked. Next, two questions about moving work around.

Key takeaways
  • origin: your copy
  • upstream: the original
  • rm --cached fixes ignore
Next up: Interview Questions: Moving Work — stash, cherry-pick and clone