git - seintzx/dotfiles GitHub Wiki
The first things you have to do is create an account on github
Now follow this sequence:
- Create a repo online on your new account
- Create a folder in your pc that will contains all the materials of the repo
I suggest you to name it as your repo mkdir <reponame>
echo "# <reponame>" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://gitlab.com/<username>/<reponame>.git
git push -u origin master
You'll be asked to insert your username and password.
Now you should have all up and running.
From now on is all up to you, just put files into your folder or create hardlink
to file that you already have ln [target] [file name]
.
You can add file in three ways:
-
git add [filename]
will simply add [filename] -
git add .
will add all modified file -
git add -i
will launch an interactive prompt to add file
After you add a file you must always commit it.
Commit a file means adding a very short description to the changes you have made
(two or three word, like fixed that
or added that
, you can write everything
you want and everyone can read it).
Nothing will be displayed on your repo untile you push them.
For doing it you have to run git push -u origin master
inside the folder in
your computer.
ssh-keygen -t rsa -b 4096 -C "[email protected]"
eval "$(ssh-agent -s)"
ssh-add ~/path/to/file
Follow this link to create an SSH key to use with gitlab.
- Go to the folder you wish to change in your local PC.
-
git remote -v
to get the remote name of what you want to change- This should be your output:
origin https://gitlab.com/USERNAME/REPOSITORY.git (fetch)
origin https://gitlab.com/USERNAME/REPOSITORY.git (push)
git remote set-url origin [email protected]:USERNAME/REPOSITORY.git
-
git remote -v
again to see if it worked
If you protect your key with a password, you will only be asked for that, otherwise you don't need to input anything to push.
Follow the instruction here
In your local folder run: git remote set-url origin origin [email protected]:<username>/<reponame>.git
Source here.
cd ~/.ssh
-
vim config
- Account 1
# account_1 Host gitlab.com HostName gitlab.com User git PreferredAuthentications publickey IdentityFile ~/.ssh/id_rsa_account_1
- Account 2
# Account2 Host bitbucket.org HostName bitbucket.org User git PreferredAuthentications publickey IdentityFile ~/.ssh/id_rsa_account2
- Account 3
# Account_3 Host github.com HostName github.com User git PreferredAuthentications publickey IdentityFile ~/.ssh/id_rsa_account_3
If you set the Host
above equal to the HostName
than you are all set up,
otherwise you need to add remote url as follows:
- Account 1
git remote add origin [email protected]_1:group_name/repo_name.git
- Account 2
git remote add origin [email protected]:group_name/repo_name.git
- Account 3
git remote add origin github.com-Account3:github_username/repo_name.git