- error: pathspec 'project'' did not match any file(s) known to git.
---- 进入到一个不是git的目录下提交出错提示。
最大的毛病就是碰到错误提示懒得去翻译什么意思,然后直接搜索相似的问题,往往就给带沟里去了。
这次遇到问题是提交时路径不对,偏偏搜了一个改变分支的博客,瞎搞一通。。。。。路越走越弯...
D:\work\AndroidPro\UHFDemo_WithAPI>git status
HEAD detached from origin/master
nothing to commit, working directory clean
D:\work\AndroidPro\UHFDemo_WithAPI>git pull
You are not currently on a branch. Please specify which
branch you want to merge with. See git-pull(1) for details.
git pull <remote> <branch>
D:\work\AndroidPro\UHFDemo_WithAPI>git pull origin
You asked to pull from the remote 'origin', but did not specify
a branch. Because this is not the default configured remote
for your current branch, you must specify a branch on the command line.
D:\work\AndroidPro\UHFDemo_WithAPI>git pull origin master
From http://...UHFDemo_WithAPI
* branch master -> FETCH_HEAD
Already up-to-date.
D:\work\AndroidPro\UHFDemo_WithAPI>git status
HEAD detached from origin/master
nothing to commit, working directory clean
D:\work\AndroidPro\UHFDemo_WithAPI>git log
commit b2c941da01563e1bf1dbc2907744161eaab8beff
Author: skye
Date: Thu Jul 12 16:58:22 2018 +0800
'translate'
commit 9ee000323e784e87f04d8e55e190974e3b7a5929
Author: skye
Date: Wed Jul 11 17:14:49 2018 +0800
'增加英文xml文件'
commit 96eab363cff9b6ad6e89ccad3db4cb4f04005a8a
Author: xtliuk
Date: Wed Jul 11 09:53:27 2018 +0800
first commit
D:\work\AndroidPro\UHFDemo_WithAPI>git push origin master
Username for
Password for:
Everything up-to-date
D:\work\AndroidPro\UHFDemo_WithAPI>git branch -a
* (HEAD detached from origin/master)
master
remotes/origin/master
D:\work\AndroidPro\UHFDemo_WithAPI>git checkout master
Warning: you are leaving 1 commit behind, not connected to
any of your branches:
b2c941d 'translate'
If you want to keep it by creating a new branch, this may be a good time
to do so with:
git branch <new-branch-name> b2c941d
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.
D:\work\AndroidPro\UHFDemo_WithAPI>git branch temp b2c941d
D:\work\AndroidPro\UHFDemo_WithAPI>git branch -a
* master
temp
remotes/origin/master
D:\work\AndroidPro\UHFDemo_WithAPI>git checkout temp
Switched to branch 'temp'
D:\work\AndroidPro\UHFDemo_WithAPI>git log
commit b2c941da01563e1bf1dbc2907744161eaab8beff
Author: skye
Date: Thu Jul 12 16:58:22 2018 +0800
'translate'
commit 9ee000323e784e87f04d8e55e190974e3b7a5929
Author: skye <zhikai.yang@supoin.com>
Date: Wed Jul 11 17:14:49 2018 +0800
'增加英文xml文件'
commit 96eab363cff9b6ad6e89ccad3db4cb4f04005a8a
Author: xtliuke
Date: Wed Jul 11 09:53:27 2018 +0800
first commit
D:\work\AndroidPro\UHFDemo_WithAPI>git checkout master
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.
D:\work\AndroidPro\UHFDemo_WithAPI>git log
commit 9ee000323e784e87f04d8e55e190974e3b7a5929
Author: skye
Date: Wed Jul 11 17:14:49 2018 +0800
'增加英文xml文件'
commit 96eab363cff9b6ad6e89ccad3db4cb4f04005a8a
Author: xtliuke
Date: Wed Jul 11 09:53:27 2018 +0800
first commit
D:\work\AndroidPro\UHFDemo_WithAPI>git cherry-pick b2c941da01563e1bf1dbc2907744161eaab8bef
[master 344786d] 'translate'
Date: Thu Jul 12 16:58:22 2018 +0800
20 files changed, 324 insertions(+), 132 deletions(-)
create mode 100644 .idea/modules.xml
create mode 100644 .idea/vcs.xml
create mode 100644 UHFDemo_WithAPI.iml
create mode 100644 UHF_API/src/main/res/values-en-rUS/strings.xml
create mode 100644 UHF_API/src/main/res/values-zh-rCN/strings.xml
rewrite app/src/main/res/values/strings.xml (69%)
D:\work\AndroidPro\UHFDemo_WithAPI>git log
commit 344786d534a4d4c6a028bcffb9d94e33248f4d1b
Author: skye
Date: Thu Jul 12 16:58:22 2018 +0800
'translate'
commit 9ee000323e784e87f04d8e55e190974e3b7a5929
Author: skye
Date: Wed Jul 11 17:14:49 2018 +0800
'增加英文xml文件'
commit 96eab363cff9b6ad6e89ccad3db4cb4f04005a8a
Author: xtliuke
Date: Wed Jul 11 09:53:27 2018 +0800
first commit
D:\work\AndroidPro\UHFDemo_WithAPI>git branch -a
* master
temp
remotes/origin/master
D:\work\AndroidPro\UHFDemo_WithAPI>git branch -D temp
Deleted branch temp (was b2c941d).
D:\work\AndroidPro\UHFDemo_WithAPI>git branch -a
* master
remotes/origin/master
D:\work\AndroidPro\UHFDemo_WithAPI>git push origin master
Username for ': skye
Password for :
Counting objects: 45, done.
Delta compression using up to 6 threads.
Compressing objects: 100% (36/36), done.
Writing objects: 100% (45/45), 12.97 KiB | 0 bytes/s, done.
Total 45 (delta 25), reused 2 (delta 0)
To http://192.168.1.91:3002/liuke/UHFDemo_WithAPI.git
9ee0003..344786d master -> master
D:\work\AndroidPro\UHFDemo_WithAPI>git branch -a
* master
remotes/origin/master
D:\work\AndroidPro\UHFDemo_WithAPI>
D:\work\AndroidPro\UHFDemo_WithAPI>Branch master set up to track remote branch master from origin.
'Branch' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
D:\work\AndroidPro\UHFDemo_WithAPI>
知识点:
- 如果需要切换远程分支到本地分支,首先
git branch -a
查看本地和远程的所有分支;remotes开头的都是远程分支;
git checkout remotes/origin/master -b master
切换到这个远程分支;
注意:-b参数后的master,指的是你本地要用一个叫什么名字的分支来追踪远程的那个分支,名字可以随便起,但一般都与远程分支同名
eg :git checkout remotes/origin/develop -b develop
新建远程/本地分支:
- 新建本地分支
git checkout -b new-branch
- 推到远程分支
git push -u origin new-branch
- 当前分支有改动后提交到远程分支
git push origin new-branch