Precondition
In my git repo, I have two branch:
- master
- release-1.0
Master branch is front of release-1.0, and this repo using Golang program language and i use vendor dir, so vendor directory in master have many files not in release-1.0 branch.
Problem
The problem is when i checkout release-1.0 branch from master branch, i get many untracked files in working directory, such like this:
[root@Chine]# git status | head
# On branch release-1.0
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# vendor/github.com/GeertJohan/
# vendor/github.com/PuerkitoBio/
# vendor/github.com/appscode/
# vendor/github.com/beorn7/
# vendor/github.com/coreos/prometheus-operator/
# vendor/github.com/daaku/
Is there any way to checkout with auto remove the untracked files?I have use git checkout -h
to check some arguments, but not found anything useful.
My workaround way is:
# git rm -rf vendor
# git reset --hard origin/release-1.0
updated at: 2019-11-14
after compare some files, i find out the reason why this happen:
The problem is that in master branch i have add vendor
directory to my git ignore list, and in release-1.0 it's not.
After following the comments below, i try git clean -fd
, it works. But i still doesn't understand why there are untracked files exsits after checkout release-1.0.