简体   繁体   中英

git commit not working with Git Bash

I am newbie in GIT. When I try to commit some files and it gives me the following warnings:

modified content, untracked content

My folder structure like:

.git

   ---- files

   ----- another-folder

   ---- .git

   ---- files

----- another-folder

---- .git

 ---- files

I was downloading git repository for learning purpose and move all downloading files into my repository. Looking forward to the answer. Thanks in advance.

The files should be added to the index (locally) first. You can do this by executing the add command like this:

git add --all

or

git add somefile.txt

After the files have been added, you can commit them.

Do the following steps. Hope it'll work

  • Remove the .git directories from those another folder (this can create submodule)
  • then run git rm -rf --cached another-folder
  • then re-added the directories with a git add -A from above
  • then git commit -m "your commit message"
  • then git push origin your-branch-name

It's making sure those directories aren't their own repository, after cleaning out git knew about them beforehand and then re-added them fresh.

Git is showing that because it is detecting some files which are modified but not yet tracked by you. To do that, run:

git add filename

This will track the file and stage them on the index. You can commit after that.

However, there might be some folders or files that you want to ignore. In that case, make a .gitignore file and add them in each line.

.gitignore

# a comment
aDir/
somefile.txt

You can also specify glob patterns to match a group of files.

# * matches 0 or more characters 
*.txt

For more details, check out .gitignore docs .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM