0

I am having trouble using git via the command line. I am trying to push up files that change reguarly and may be deleted from my local drive at any point and that would need to be pushed as well.

I know how to do this sort of thing via sourcetree but unsure what to do on the command line

I currently have:

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

I want to just basicaly push to the master without any care for what is there but I do not want to use force as I want to see the history of the changes that are made. How do I do this as I a currently getting errors about everything being out of sync.

Cheers

1
  • 3
    What's the error output? Commented Aug 8, 2014 at 11:33

1 Answer 1

1

You are doing this:

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

But your local repository is not aware of the remote contents. So it can not push to it.

Here's one approach:

 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 

If you don't need to push your changes to master you could just push your local branch to a remote one by issuing

git push -u origin feature_branch_name

If you are not sure what your repositories config is (to averview the remote connections etc pp)

git config -l --local (skip the local if you want system wide settings shown)
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you for the response, it was very helpful! I found out that the reason what I was doing wasn't working is because my repo was so out of sync and back to front it didn't know what it was doing. With your help and creating a new repo I now have it working. Thank you very much.
You are welcome! I always recommend gitready.com to my coworkers or the tutorials from github.com

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.