cd existing_folder
git init
git remote add origin https://blah.git
git add .
git commit
git push -u origin mastergit config pack.windowMemory 10m
git config pack.packSizeLimit 20m
git config pack.threads 1
- Get a particular commit for a file:
git checkout xxxx file. This is just to test a given commit. - To revert the last commit:
git revert xxxxx. See here - Return from a detached HEAD state:
git checkout masterorgit checkout -
Create the new branch:
git checkout master
git branch new-branch
git checkout new-branch
Then code, and commit on the new branch.
Finally, when you need to merge:
git checkout master
git merge new-branch
This merges everything locally. Solve merge conflicts. Finally:
git push origin master
To remove a remote branch: git push -d origin BRANCHNAME
To list remote branches:
git fetch
git branch -a
To switch to a branch: git checkout branchname
$ git config --global --list
credential.helper=store
$ git config --global --list
core.sshcommand=ssh -vvv
- To use SSH, make sure git account has a
/home/githome dir + SSH server allows use ofauthorized_keys. - See https://discuss.gogs.io/t/how-to-config-ssh-settings/34
Example of SSH config file ~/.ssh/config:
Host github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_xxxx
It is even possible to use different identities for different repositories on GitHub:
Host github.com/cryptax
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
Host github.com/anotheridentity
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_other