How to set a GIT HUB user in .travis.yml? - github

How to set a GITHub user name in the below Git clone command?. I am new to GIT HUB and planning to keep this command in .travis.yml file.
My .travis.yml file should execute irrespective of the Git Hub user. Could you please help me in setting this up.
git clone https://github.com/**gitgubusername**/repositoryname/

If the repository is public, you don't need to setup a user.
The git clone command itself will be enough.
Travis will infer the url from where the .travis-ci.yml file is.
For private repos accessed by Travis, see "Private Dependencies".

Related

Does GitHub use bare repositories under the hood?

Recently, I discovered that git could be initialized with a --bare flag (e.g. git init --bare). It creates a local repository without a working tree (workspace). As far as I understand, such repositories can be used as a remote from which you can clone, pull and push.
Do GitHub and similar services use "bare repositories" under the hood?
I'm wondering because whenever I create a local repo and push it to a remote service (like GitHub, GitLab, Bitbucket, etc.), I don't create the bare repo myself and I'm not sure if it was created at all (implicitly by GitHub). If it wasn't created, then what is tracking the files/history?
tl;dr
Locally, I can do something like this
-- Step 1. Create a local bare repository
$ mkdir bare-repo/
$ cd bare-repo/
$ git init --bare
-- Step 2. Clone a non-bare repo and push changes
$ mkdir non-bare-repo-1
$ cd non-bare-repo-1
$ git clone ../bare-repo .
$ touch file.txt
$ git add .
$ git commit -m "Add file.txt"
$ git push (it pushes changes to the local remote a.k.a. non-bare/)
And I can create another folder and another and all of them will refer to a single (local) bare-repo/ which tracks changes of all cloned repositories.
I wonder if GitHub uses this approach under the hood, or if the bare repositories are used for something else...
Answering my own question
Do GitHub and similar services use "bare repositories" under the hood?
Yes
It looks like bare git repositories were designed to be used as remote instances and GitHub has to use them to get it to work.
P.S.
Related answer by #VonC
It seems that GitHub repository can work as working repository and bare repository at the same time, does that mean GitHub repository is developed from git bare repository
No, Git repos on GitHub are bare, like any remote repo to which you want to push.
Related answer by #duncan
Short answer
A bare repository is a git repository without a working copy, therefore the content of .git is top-level for that directory.
Use a non-bare repository to work locally and a bare repository as a central server/hub to share your changes with other people. For example, when you create a repository on github.com, it is created as a bare repository.
So, in your computer:
git init
touch README
git add README
git commit -m "initial commit"
on the server:
cd /srv/git/project
git init --bare
Then on the client, you push:
git push username#server:/srv/git/project master
...
I believe so. You can in fact create a GitHub repo and deselect all the auto created files (e.g. README.md, LICENSE). You're provided a list of instructions to init, commit and push the repo.

Why can't I access my Github repo from CLI

I created a repo on Github, and I was able to commit code scripts to the repo from the Git Bash cli. Now, I have entered the master of my repo from the cli with cd reponame, but I can't commit new files to my Github repo of the same name. I can stage and add, but the command git commit -m "message" says my code is committed but when I go and refresh the repo on Github, there is no sign of the file. It didn't behave like this when I first setup the repo. Please, is there something I am not getting right?
after committing use git push so ur changes go to github and can be seen

Connect to github server

I have the ip, useename and password of the github server, which uses gitlab, and I need to connect to it and manage files. What should I do?
I'm assuming you're asking how to manage/change files within a git repository. If you're asking something else, I've missed the point, apologies.
Firstly you will need 'git' on your local machine - install it with your package manager or download and install it from the git website.
Once git is installed you can clone a repository (which contains a set of files, and ends in .git) using the git clone command. Run git clone --help for more information on this, but if you already know the address of your git server and the path to the repository, it will look something like as follows:
git clone https://git-server.url/path/to/repo.git
Note that the URL you should use will depend on the configured transport protocol (git, ssh, http[s]) of your git server.
Next, you should makes some local configurations, for example, from a terminal:
git config user.name "your_username"
git config user.email "someone#example.com"
You can add --global to both of these command if you want these changes to persist outside of the current git repo.
Having a cloned repository automatically checks out an initial 'branch' on which you can make changes to files within your repository. See the git docs for a detailed explanation of a branch.
Files can be added, removed or renamed/moved using git add, git rm or git mv respectively.
Finally, you must commit your changes and push them
git commit -m "A message describing your changes"
git remote will confirm the name of the default remote (repo location). In this case, it is assumed to be origin. You can then push your changes to an existing branch (viewed using git branch -r), assumed to be master below:
git push origin master
Here you would be merging your master branch with the remote one. Clearly your permissions/project conventions will dictate what you can/should do to this repo.

Is it possible to push to a new remote on VSTS git?

Is it possible to create a new VSTS Git remote repository from a Git client?
Right now, I have to go to visualstudio.com first to create the new repository before adding and pushing it from PC git, using the url created in VSTS.
I tried the following:
git remote add brandnew xx.visualstudio.com/PROJECT/_git/qqq
git push brandnew --all
where I am the owner of xx.visualstudio.com and PROJECT is an existing project, but qqq does not exist.
The above gives me:
remote: TF401019: The Git repository with name or identifier qqq does not exist or you do not have permissions for the operation you are attempting.
fatal: repository 'https://xx.visualstudio.com/PROJECT/_git/qqq/' not found
Yes, it's possible.
Even you can not create a VSTS git repo by git command line by default, but you can achieve it via git hooks.
And for the reason why you can create and publish new VSTS git repo via VS, it that VS will create the new VSTS git repo by API not by git commands.
So if you want achieve this feature in git command line, you can use pre-push hook for assistance. Functions need to achieve in pre-push hook as below:
Detect if the remote repo https://xx.visualstudio.com/PROJECT/_git/qqq exist or not.
If the repo is not exist in VSTS, then create by REST API.

Not able to upload file in the github repository

I am new to GitHub and I have to submit one assignment through GitHub.
I have been reading this blog for uploading files through github, but am not able to see any button labeled Upload files on my home screen of the repository
What am I missing?
See the "or push an existing repository from the command line" to push existant files to your repository. You won't have to load them by a form but with your command line from your project.
Github does not work like cloud storage platform. You actually need to have git installed on your computer in order to be able to push code to your repositories.
First of all, you need to install git( download links here ).
Then you need to init your local repositories with git init. Caution you need to run this command inside the directory your code is placed.
Run git add --all to stage the changes
Run git commit -m "your message" to commit your changes
Run git add remote origin (repo_link or ssh) to add your Github repo as a remote repository
Run git push -u origin master to push your master branch to remote origin
This might look a lot at first place but, you 'll get used to it really soon
Alternative
You can also the git and GitHub GUI which are much friendlier for a beginner.