Git push problems - linux

i am new to webdeveloping and stuff, I want to push my html and css files to github but after I do git commit and git push origin master I get this error:
fatal: 'origin' does not appear to be a git repository
fatal: Could not read from remote repository.
Sorry if this is a silly question, but I am new and I couldn't find the answer online. I looked into several tutorials and did not succeed in pushing my page to GitHub. I have managed to update my README.md file using this tutorial: http://git-scm.com/book/en/v2/Git-Basics-Getting-a-Git-Repository

From the GitHub documentation, you need to configure your origin to point to the GitHub remote:
git remote add origin https://github.com/user/repo.git
# Set a new remote
git remote -v
# Verify new remote
Replace https://github.com/user/repo.git with the actual path to your remote repository on GitHub.

The issue is that you don't have the repository uploaded remotely (ie. on Github).
Follow these instructions if you want the repository pushed to GitHub: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/. You seem to have done the first 6 steps already (up to committing). Note: you require a GitHub account for this and the repository will be publicly available to read unless you pay (don't worry - people won't be able to write into the repository unless you let them).

Related

Storing results of BFG to new project in Gitlab

I've successfully (I think!) removed large files from a gitlab project mirrored on my local drive using BFG. I don't want to replace the existing gitlab project (for safety reasons), but instead want to push to a new test gitlab project. Here's the commands I've done successfully so far:
git clone --mirror git#git.domain.com:architecture-team/IOMobile.git
java -jar bfg.jar --strip-blobs-bigger-than 100M IOMobile.git/
cd IOMobile.git
git reflog expire --expire=now --all
git gc --prune=now --aggressive
Those commands seem to have done the trick, now how do I reset the origin to:
git#git.domain.com:architecture-team/testiomobile.git
...and then push the mirror into the new project? I'm not sure how to reset the origin on a mirror and want to make sure I don't change the original project.
Do I just do a simple
git push
or do I need
git push --mirror
Thanks for any help
-Owen
I think in this case it does not matter if you specify --mirror or not. Since you cloned it already with the --mirror flag, a normal git push will update all refs on the remote server. This is also described at the bfg docs: https://rtyley.github.io/bfg-repo-cleaner/
But there is a gotcha you could run into. If you see this error message while pushing:
remote: GitLab: You are not allowed to force push code to a protected branch on this project.
Then you have to enable Allow force push option in the GitLab project settings at URL https://git.domain.com/architecture-team/testiomobile/-/settings/repository
After the push you should disable the Allow force push again.

Folder's content are empty after pushing into bitbucket

I wanted to push folders from my local repositories into bit bucket. Somehow I was unable to do that.
I got the solution somewhere to use
$ git push -f origin master
which resolved the issue but erased all lines of code.
This is my very first use of bit bucket. How to get all content back?
Now, I deleted previous repository and created the new one. Typed below but getting error
$ git remote add origin
https://PoojaThapa#bitbucket.org/PoojaThapa/git-poojatest.git
fatal: remote origin already exists.
$ git push origin
fatal: HttpRequestException encountered.
An error occurred while sending the request.
remote: Not Found
fatal: repository 'https://PoojaThapa#bitbucket.org/PoojaThapa/git-
test.git/' not found
please suggest.
Assuming you have a repository in your current directory you can add a remote with any name using:
git remote add <remote-name> <url>
You are getting an error with your first command because a remote already exists called origin.
Try git remote -v to see which remotes you have already got defined.
In your case I think you want to create a new remote (with a different name, for example bitbucket), so
git remote add bitbucket https://PoojaThapa#bitbucket.org/PoojaThapa/git-poojatest.git
Verify that the remote was created correctly using git remote -v, then you can push to the new remote using <remote-name>/<branch>:
git push bitbucket/master
"repository not found" implies that the origin URL is incorrect. List your current remotes with git remote -v, and double-check that you have the correct URL(s) listed. (You should be able to go to the URL in your browser.)
If something is incorrect, you can fix it with git remote set-url origin correct-url-goes-here.

How do i add and sync my local git on server? What is bare repo?

I am using git from a long time but never set it up on server. Refereeing to this Git: move existing repository from PC to server, clone from server
I have initiate a bare repo on server but while adding origin in local
"git remote add origin server:path/to/repo" i have no idea what to add here. My site is getwalkwel.com and user is getwamld
Thanks
Origin is the name of a remote which is typically created automatically when you clone a repo from another repo. The origin reference in the cloned repo will be created to point back to the repo that was cloned from.
In your case, where the bare repo was actually created later from your working repo, you will create origin in your working repo to point back to your new bare repo.
This is done with:
git remote add origin /barerepo/fullname
If your bare repo is going to line on a different machine, then you need the URL to reach the repo instead of just a file path.
For instance, you might have myuser#myserver:path/to/repo
Bare repository in Git is a repository which only contains version control information only in fact this will not have .git sub-directory or any working files.
This kind of repository is helpful when you need to share or divide your work between few people for example in work environment you and your team mates are working on same project and you all need to see changes and all needs to do push to repository in this case this repository is more useful.
You can add the remote repository to local git repo
$ git remote add origin ssh://myserver.com/var/git/myapp.git
pushing to remote repository:
to push our local master branch to the origin's master branch. You can do that using the git push <target> <local> command.
$ git push origin master
click here for more information on how this works

How does Git know which repository to push to?

I'm a complete noob when it comes to version control, but I recently started using GitHub to host some of my projects. I blindly use the command git push origin master to push changes to either of the two repositories. I don't understand how Git knows which repository to push to. I use the same command to push to each. Does the directory I'm in have anything to do with it?
Thanks for clearing this up for me.
A word of advice, "blindly use"ing anything is a bad idea.
git has a system of remotes which allows to specify URLs and transports to repositories other than the one where you're working. git push origin master pushes the current branch to the remote called origin as the branch master. You have a remote called origin. This is created by default when you clone a repository from a URL.
git remote add origin http://abc.com/def/ghi.git tells git the url that remote 'origin' points to.
When you use git push origin master, you aren't pushing to two repositories - you are pushing to the master branch in your repository who's name (alias) is origin.
Think of it like this:
I'm pushing my stuff to origin which is my repository address. What am I pushing there? My master branch.
If you are new and set git up yourself through git init, you probably aren't pushing to two repositories. Run this command to see what your remotes are:
git remote -v
This will return something like (assuming you have a git hosting service like github):
blahblah git#github.com:yourGithubName/fileName.git (fetch)
blahblah git#github.com:yourGithubName/fileName.git (push)
git#github.com:yourGithubName/fileName.git is your repository address. Some addresses are prefixed by https:// .
Git repositories contain a .git directory that contains metadata about the repository. That's what Git uses to determine where to push your changes.

git server and client set up in linux

i am new to git and now i am trying to set up a git server and want to access the server from client.
referred many links but those are not helping me. i tried with the link http://davedevelopment.co.uk/2010/12/05/how-to-install-gitolite-on-ubuntu-10-10-maverick-meerkat.html. after the final step in the document i didn't know how to proceed.
can anyone give the details?
thanks in advance.
if you have cloned a repository on your client you are ready to start coding...
git commit
to commit changes locally, and
git push
to push your changes to the server.
What is missing on the above answers is how to push on the server a new repo.
Suppose that in the gitolite config file you have a repo named my_repo, you can add to the server an existing local repo this way:
cd my_repo
git remote add gitolite git#your.git.server:my_repo
git push gitolite master
You have to type ONLY ONCE the second line above. After that, you only have to push.

Resources