-1

Totally new to using git. I used "git commit" to commit some files which I believe were staged. However, I now want to know where exactly these files went. How do I check this?

whatwhatwhat
  • 1,068
  • 2
  • 19
  • 38
  • 1
    What do you mean by `"where exactly these files went"`? Unless you deleted the files in the commit, they didn't go anywhere. Git is a repository-based version control system. When you make a commit, _every_ file gets versioned. – Tim Biegeleisen Dec 23 '15 at 03:21
  • @TimBiegeleisen so as a simple example - if I'm tracking 1 file in a specific directory, and then I use `git commit`, the file is still in the same spot right? If so, then I don't understand what a commit is. – whatwhatwhat Dec 23 '15 at 19:29
  • A commit is a snapshot of _all_ the files in your repository. Imagine a little gremlin with a camera taking a picture of your entire project all at once. – Tim Biegeleisen Dec 23 '15 at 23:29

3 Answers3

0

git log will show you the most recent commits. You can see a diff of the most recent commit with git show, too, so you can see what files were changed.

NevilleS
  • 1,189
  • 7
  • 12
0

Read more about

git status

any file should be untracked or tracked (remember about ignored). If your file not under "Untracked" part so it already staged.

Vitaly Velikodny
  • 1,162
  • 9
  • 18
0

Git is a decentralized version control system, which means that committing does not share your code with anyone else. Instead, when you commit, the files stay locally on your computer and are committed to your local version of the git repository. These files only move to other machines when you push your code.

Nick McCurdy
  • 11,551
  • 3
  • 38
  • 65
  • So if I have a repo that contains my project and I'm tracking every file in there, and I commit a change to a file, this then saves those changes over the file in the directory? – whatwhatwhat Dec 23 '15 at 19:30
  • If you're the only person committing and you're not pulling anyone else's code, git won't overwrite any files. It's simply tracking your changes to the project on your filesystem over time. Whenever you save a file in your editor, it's saved to your filesystem as usual, you're just telling git to remember that you made that change in case you want to revert it in the future or share your change with someone else. – Nick McCurdy Dec 23 '15 at 22:38
  • It seems like you're used a a centralized version control workflow (like with CVS or SVN), but git is a decentralized system, meaning every user has a copy of the entire repository. I recommend reading some git books and/or tutorials, and the [official git documentation](http://git-scm.com/doc) is a great start. – Nick McCurdy Dec 23 '15 at 22:40