1

So, in a workbench, I have created a project within a folder that is my git repository. Now, I want to pull the current changes. However, I cannot, because apparently I have unstaged changes in my local repository. The project that I have created has nothing in it. I don't want to upload it to the git repository, because one of my teammates has finished this part of the project already and uploaded it to the git. How can I delete these unstaged changes ?

This is the message that I get after git pull

 git status
On branch master
Your branch is behind 'origin/master' by 10 commits, and can be fast-forwarded.
  (use "git pull" to update your local branch)

Untracked files:
  (use "git add <file>..." to include in what will be committed)

        Software Sourcecode/Node/Projects/Multi/Applications/LoRa/End_Node/SW4ST    M32/B-L072Z-LRWAN1/mlm32l07x01/Debug/mlm32l07x01.bin
        Software Sourcecode/Node/Projects/Multi/Applications/LoRa/End_Node/SW4ST    M32/B-L072Z-LRWAN1/mlm32l07x01/Debug/mlm32l07x01.elf
        Software Sourcecode/Node/Projects/Multi/Applications/LoRa/End_Node/SW4ST    M32/B-L072Z-LRWAN1/mlm32l07x01/Debug/output.map
        Software Sourcecode/Node/Projects/Multi/Applications/LoRa/End_Node/SW4ST    M32/B-L072Z-LRWAN1/mlm32l07x01/MT5803_Pressure_Temperature
        Software Sourcecode/Node/Projects/Multi/Applications/LoRa/End_Node/SW4ST    M32/B-L072Z-LRWAN1/mlm32l07x01/Projects/
        Software Sourcecode/Node/Projects/Multi/Applications/LoRa/End_Node/SW4ST    M32/B-L072Z-LRWAN1/mlm32l07x01/mlm32l07x01 Debug.cfg

nothing added to commit but untracked files present (use "git add" to track)
  • Use `git clean -fdx` https://stackoverflow.com/questions/8200622/how-to-remove-untracked-files-in-git – Number945 May 06 '18 at 09:00
  • 2
    Possible duplicate of [How to remove local (untracked) files from the current Git working tree?](https://stackoverflow.com/questions/61212/how-to-remove-local-untracked-files-from-the-current-git-working-tree) – Jonathan Wren May 06 '18 at 09:01
  • @ Breaking Benjamin: Thx man, this did the trick –  May 06 '18 at 09:31

3 Answers3

1

That message tells you about all the local files preventing the pull operation. You could simply delete them, or move them away.

You can use "git stash" to temporarily move files out of the way!

GhostCat
  • 137,827
  • 25
  • 176
  • 248
  • Although it does the trick, git stash should not be used to remove unrequired files/directories. Stashing is meant for saving patches or work which may be required at some point of time in future. git clean -fd is you friend dear to get rid of untracked files. Also, if you happen to see these files quite often and are generated at build/run time you may want to add them to git ignore. Read this doc for more detailed explanation. – beingmanish May 07 '18 at 04:26
1

bin, elf and map files are the output of the compilation process, and typically we do not want them saved in the git repo, but we do want to to be allowed to live in our workspace because they are the output of the build process.

Git has a method for dealing with this type of file. There is a file called .gitignore Place the filenames of the files you want ignored in the .gitignore file, and git will no longer bug you about their presence. It is customary to put the .gitignore file in the root dir of you repo, i.e. in the same dir as the .git directory.

Also, it is common to check in the .gitignore file, so that all users of the repo ignore the common build products and don't commit them.

There is a pretty good discussion of how to do this here: https://www.atlassian.com/git/tutorials/saving-changes/gitignore

Randy Leberknight
  • 1,363
  • 9
  • 17
0

git clean -fd is you friend dear to get rid of untracked files.

However, in case your untracked directory is managed by a different git repository, it is not removed by default. Use -f option twice if you really want to remove such a directory.

Also, if you happen to see these files quite often and are generated at build/run time you may want to add them to git ignore. Read this doc for more detailed explanation.

beingmanish
  • 1,040
  • 8
  • 21