【问题标题】:how to push to git from Terminal / Command Line如何从终端/命令行推送到 git
【发布时间】:2016-08-21 18:28:37
【问题描述】:

我在文件夹中添加了一个文件用于 Git 上传。我可以在未暂存的 SourceTree 中看到该文件夹​​。如何使用终端命令将文件推送到在线存储?

我发现我需要先 cd 到本地存储库,我这样做了:

cd /Users/mainuser/Desktop/Projects
git add -A .

使用git status 检查状态并输出:

On branch master
Your branch is up-to-date with 'origin/master'.
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

    new file:   ios_projects/2016/Untitled copy 2.rtf // this is the file I want to upload

现在呢?如何提交并在线推送?

【问题讨论】:

    标签: git command-line terminal


    【解决方案1】:

    接下来就是提交使用,然后推送到你想要推送的任何分支

    git commit -m 'Some message about the change'
    
    git push origin 'branch-name'
    

    【讨论】:

    • 太好了!您是否知道如何将当前日期和时间作为提交消息提交?
    • 嗯不是真的,您当然可以手动将日期和时间添加到提交消息中。我知道您肯定会在提交日志中或转到 git commit 选项卡时看到提交日期。希望有帮助
    【解决方案2】:

    原来就是这么简单:

    cd /Users/mainuser/Desktop/YourFolder
    git add -A .
    git commit -m 'commit message from terminal'
    git push
    

    编辑:如果你只使用git commit而不使用-m,你将进入一些编辑器来输入提交信息,我不知道如何退出。

    【讨论】:

      【解决方案3】:

      试试下面的cmd:

      $ git status
      $ git add <file_name>
      $ git commit -m "<msg>"
      $ git push origin <branch_name>
      

      【讨论】:

        猜你喜欢
        • 2016-08-16
        • 2018-03-28
        • 1970-01-01
        • 2014-03-04
        • 1970-01-01
        • 1970-01-01
        • 2016-09-17
        • 1970-01-01
        • 2017-07-08
        相关资源
        最近更新 更多