sudo apt install git-all sudo apt-get remove git sudo apt-get remove --auto-remove git // with dependencys // If you also want to delete configuration and/or data files of git from Ubuntu Trusty then this will work: sudo apt-get purge git sudo apt-get purge --auto-remove git // with dependencys
git config --global user.name YOUR_USRE_NAME // set username git config --global user.email YOUR_EMAIL // set email git config --global user.name // show username git config --global user.email // show email git config --global --list // check all info // config file is in : nano ~/.gitconfig
git init git add . git commit -m "messate" git push origin master //git push
git checkout . // ignore change
git fetch origin // see change
git merge origin/master // merge
git checkout master // switch to master brach
git pull origin master
git clone https://gitlab.com/mabnagroupeaf/note-server.git //clone via https - You can either clone it via HTTPS or SSH. git clone [email protected]:mabnagroupeaf/note-server //clone via ssh
git clone https://USER_NAME:[email protected]/mabnagroupeaf/shop-project // clone via https - with username and password from private project in another accout
/* If you chose to clone it via HTTPS, you’ll have to enter your credentials every time you pull and push. With SSH, you enter your credentials only once. */
$ git config credential.helper cache $ git push http://example.com/repo.git Username: Password:
[work for 5 more minutes] $ git push http://example.com/repo.git [your credentials are used automatically]
// FOR GITLAB
//Create a new repository
// NOT NEED TO CREATE FOLDER***********
git clone https://gitlab.com/mabnagroupeaf/note-server
cd test
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master
//Push an existing folder cd existing_folder git init git remote add origin https://gitlab.com/moradiemails/test.git git add . git commit -m "Initial commit" git push -u origin master
//Push an existing Git repository cd existing_repo git remote rename origin old-origin git remote add origin https://gitlab.com/moradiemails/test.git git push -u origin --all git push -u origin --tags
// ---------------- Errors
error: RPC failed; curl 56 GnuTLS recv error (-9): A TLS packet with unexpected length was received.
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
// this error solved by:
It happens more often than not, I am on a slow internet connection and I have to clone a decently-huge git repository. The most common issue is that the connection closes and the whole clone is cancelled.
After a lot of trial and errors and a lot of “remote end hung up unexpectedly” I have a way that works for me. The idea is to do a shallow clone first and then update the repository with its history.
$ git clone http://github.com/large-repository --depth 1 $ cd large-repository $ git fetch --unshallow
// change previous commit first : git add . git commit --amend git push --force // if you do not add file to stage this comman just change message of commit
git rm -r --cached bin/
// create ssh key for git - github ------------------------------------ cd ~/.ssh ssh-keygen -t rsa -b 4096 -C "[email protected]" press enter [default create id_rsa] or enter your own rsa name like github_rsa its important to you use form : /c/Users/Shaparak/.ssh/id_rsa_github_laptop_morteza password password
clip < ~/.ssh/id_rsa_github.pub
add containt of rsa.pub to github
// add key to ssh-agent
eval $(ssh-agent -s) // check ssh-aget is running
ssh-add ~/.ssh/id_rsa_github // add key to ssh-agent
enter password
// check connection is done or not ssh -T [email protected]
// add this key to github or gitlab ------------------------------------
// chekc git remote mode : https or ssh
git remote -v
// change git remote https to ssh
git remote set-url origin [email protected]:USERNAME/REPOSITORY.git
// change git remote ssh to https
git remote set-url origin https://github.com/USERNAME/REPOSITORY.git