$ git rm --cached .idea
$ git rm --cached -r .idea
del .git\index.lock
git config --global user.name "你的 GitHub 用户名" 与 git config --global user.email "你的 GitHub 用户名对应的 email 地址"。然后再键入 git commit --amend --reset-author
//拉去代码
git pull git pull <远程主机名> <远程分支名>:<本地分支名>
git merge <branch> # 将branch分支合并到当前分支
//推代码
git push origin develop:develop
git push origin develop:master
1.新建新项目的文件夹,使用终端
本地项目上传线上
git init
git remote add origin "地址url"
git fetch --all
Fetching origin
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From https://git.oschina.net/gongyun-android/nongwxvender
* [new branch] develop -> origin/develop
* [new branch] master -> origin/master
MacBook-Pro:nongwxvender chenmengjia$
git reset --hard origin/master
HEAD is now at 0ab6c4c Initial commit
MacBook-Pro:nongwxvender chenmengjia$
3.删除
git branch -d "xxx"
git branch -D retro
4.关联
//关联之前必须执行指向指针
git pull --rebase origin master(使用了git fetch -- all就不用了)
git branch --set-upstream-to=origin/develop develop(本地和远端关联)
//成功后提示
Branch master set up to track remote branch master from origin.
error: failed to push some refs to 'https://git.oschina.net/chenmengjia1990/test.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
在使用git 对源代码进行push到gitHub时可能会出错,信息如下
此时很多人会尝试下面的命令把当前分支代码上传到master分支上。
$ git push -u origin master
但依然没能解决问题
出现错误的主要原因是github中的README.md文件不在本地代码目录中
可以通过如下命令进行代码合并【注:pull=fetch+merge]
git pull --rebase origin master
//可能出现的提示
chenmengjias-MacBook-Pro:starglobal-android chenmengjia$ git pull --rebase origin master
From https://git.oschina.net/gongyun-android/star_global
* branch master -> FETCH_HEAD
It seems that there is already a rebase-apply directory, and
I wonder if you are in the middle of another rebase. If that is the
case, please try
git rebase (--continue | --abort | --skip)
If that is not the case, please
rm -fr "/Users/chenmengjia/Desktop/star_global/starglobal-android/.git/rebase-apply"
and run me again. I am stopping in case you still have something
valuable there.
chenmengjias-MacBook-Pro:starglobal-android chenmengjia$ git rebase --skip
5.强制覆盖
git fetch --all
//打标签
git tag -a v2.004 -m "v2.004"
git push origin --tags
git checkout -b develop origin/develop
//移除远程仓库
git remote rm origin
git rebase --skip
cd ..
cd ~
cd desktop
git reset --hard develop
git push origin master --force