通过命令行使用git

时间:2014-08-08 11:16:26

标签: git github cmd

我无法通过命令行使用git。 我试图推高文件的变化,可能会在任何时候从我的本地驱动器中删除,也需要推送。

我知道如何通过sourcetree做这类事情,但不确定在命令行上做什么

我目前有:

git init
git add --all
git commit -m "Test"
git remote add *"Repository"*
git push econnectConfig master

我想基本上向主人推送而不关心那里有什么,但我不想使用武力,因为我想看到所做的更改的历史。我如何做到这一点,因为我目前正在收到有关一切不同步的错误。

干杯

1 个答案:

答案 0 :(得分:1)

你这样做:

git init -> initialize a git repository in the current directory
git add --all -> add all files
git commit -m "Test" -> commit which files? git commit -a -m 'test' will add all
git remote add *"Repository"* -> tell you local repository where to connect to
git push econnectConfig master -> push your changes to the remote master branch

但是您的本地存储库不知道远程内容。所以它无法推动它。

这是一种方法:

 1.) git fetch -> sync your local with the remote repo 

   2.)  git branch -a -> show all branches: remote and local

   3.)  git checkout master -> checkout the remote master branch to your local repo 

   4.)  git checkout [yourlocalrepo] -> (econnectConfig?) switch to you local branch again

   5.)  git rebase master -> update [yourlocalrepo] to master branch and apply the changes of [yourlocalrepo] on top of them

   6.) git checkout master -> back to your local master branch

   7.) git rebase [yourlocalrepo] -> apply the changes from [yourlocalrepo]  to the master branch

   8.) git push -> push your local changes to the master branch on the remote server 

如果您不需要将更改推送到主人,则可以通过发布

将本地分支推送到远程分支。
git push -u origin feature_branch_name

如果您不确定您的存储库配置是什么(要查看远程连接等等)

git config -l --local (skip the local if you want system wide settings shown)
相关问题