gitee 码云Mac推送本地代码步骤

2023-12-12  本文已影响0人  天山海梦

1.未建立 git 仓库:
git config --global user.name "张三"
git config --global user.email "123456789@qq.com"

查看一下当前的设置是否都有:
git config --list

创建 git 仓库:
mkdir ios-abc-newA
cd 本地项目路径
git init
touch README.md
git add README.md
git commit -m "first commit"
git remote add origin https://gitee.com/demy_dcw/ios-abc-new.git
git push -u origin "master"

此刻我们可看到项目文件夹中多了一个 README.md文件。

已有仓库:
cd 本地项目路径
git remote add origin https://gitee.com/demy_dcw/ios-abc-new.git
git push -u origin "master"

推本地代码到Gitee上步骤:
1.git add .
2.git commit -m "备注"
3.git push -u origin "master"

如有报错:
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: .DS_Store

Untracked files:
(use "git add <file>..." to include in what will be committed)
abc/Classes/Alipay/libcrypto.a
no changes added to commit (use "git add" and/or "git commit -a")

4:git add abc/Classes/Alipay/libcrypto.a

一.报错:
Git提交报错 ! [rejected] master -> master (fetch first) error: failed to push some refs to

解决方法一:弹制推送命令
git push -f origin master

解决方法二:代码合并

  1. git pull --rebase origin master (拉取Git代码)
  2. git push origin master (推Git代码)

二.报错:
fatal: Unable to create '/Users/张三/Desktop/abc7.0/abc-ios/.git/index.lock': File exists.

Another git process seems to be running in this repoabcsitory, e.g.
an editor opened by 'git commit'. Please make sure all processes
are terminated then try again. If it still fails, a git process
may have crashed in this repository earlier:

解决:rm -f ./.git/index.lock

三.初始化git项目时,报错 Reinitialized existing Git repository in.......

解决:表示该路径中已经存在.git文件了,可在当前文件下,在控制台中输入 ls-a 查看,有.git 的话,使用 rm -rf .git 删除之后重新初始化git init 即可;

上一篇下一篇

猜你喜欢

热点阅读