【问题标题】:What can I do to use git properly in Terminal?我该怎么做才能在终端中正确使用 git?
【发布时间】:2018-02-04 17:02:08
【问题描述】:

无论我尝试什么,我都无法让它工作,我被告知要使用

git config --global user.name "Your Name"
git config --global user.email you@example.com
git commit --amend --reset-author:

但我总是到了一个我不知道自己在做什么的地方,甚至不知道如何安全地离开那个环境。

.git/ 位于我的 memory_game 文件夹中,其中包含我的项目代码。 memory_game 文件夹被保存——让我给你看:

~/fundamentals/memory_game

.git/ 应该放在基础而不是 memory_game 中吗?

我觉得如果我不小心行事,我可能会损坏系统。如果可以,请帮助我,我只是在努力学习。感谢您的时间!

以下是我最近的终端活动:

在主分支上

还没有提交

未跟踪的文件:(使用“git add ...”来包含将要跟踪的文件 承诺)

.DS_Store
css/
images/
index.html
js/ nothing added to commit but untracked files present (use “git add” to track)

您的姓名和电子邮件地址是根据以下条件自动配置的 您的用户名和主机名。请检查它们是否准确。你 可以通过显式设置来抑制此消息:

git config --global user.name "Your Name"
git config --global user.email you@example.com

完成此操作后,您可以通过以下方式修复用于此提交的身份:

git commit --amend --reset-author
11 files changed, 202 insertions(+)
create mode 100644 .DS_Store
create mode 100644 css/style.css
create mode 100644 images/.DS_Store
create mode 100644 images/back.png
create mode 100644 images/king-of-diamonds.png
create mode 100644 images/king-of-hearts.png
create mode 100644 images/queen-of-diamonds.png
create mode 100644 images/queen-of-hearts.png
create mode 100644 index.html
create mode 100644 js/main.js

User-MBP:memory_game user$ git push origin master

fatal: ‘origin’ does not appear to be a git repository
fatal: Could not read from remote repository.

请确保您拥有正确的访问权限和存储库 存在。

  Users-MBP:memory_game usernameishere$ git status
  On branch master
  nothing to commit, working tree clean
  Users-MBP:~ username$ cd fundamentals
  Users-MBP:fundamentals username$ cd memory_game

Users-MBP:memory_game 用户名$ ls -a

. .DS_Store   css index.html
… .git    images  js

Users-MBP:memory_game 用户名$ git init

重新初始化现有的 Git 存储库 /Users/用户名/fundamentals/memory_game/.git/

Users-MBP:memory_game 用户名$ git status

在分支 master 上没有提交,工作树干净

【问题讨论】:

  • origin 未设置,因为您尚未设置任何遥控器。你打算push去哪里?你需要为此设置一个遥控器。

标签: git macos github terminal


【解决方案1】:

git config --global 命令只是设置一些全局配置,告诉 git 你是谁。 (您只需要这样做一次。当然,您应该使用您的真实姓名和电子邮件。)

.git 目录应该位于 ~/fundamentals/memory_game 还是 ~/fundamentals 取决于您是只想管理 memory_game 还是所有基础知识。

输入git push 将尝试将您的提交推送到某个远程位置。你从来没有告诉 git 那个地方的位置。因此错误。

这些确实是一些非常基本的问题。您首先需要了解基本概念。请看一些关于git的介绍:

【讨论】:

【解决方案2】:

检查git remote -v 的输出。它显示了当您运行git push origin master 时您的本地更改将被推送到的远程存储库。如果您没有将 origin 设置到遥控器中,则需要通过get remote add origin <link to your remote repository> 进行设置。

【讨论】:

    猜你喜欢
    • 2015-02-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-13
    • 2010-09-16
    • 2020-11-19
    • 1970-01-01
    相关资源
    最近更新 更多