#1418
[Git] How-To
To test GIT commands :
learngitbranching.js.org
Create a new branch (local and remote) :
git checkout -b new_branch #< create a new local branch with a copy of your code git push origin new_branch #< pushes to the server git push --set-upstream origin new_branch
To define the origin after pushing the new branch :
git branch --set-upstream-to=origin/<branch> new_branch
Clone into specific directory :
git clone http://.... LOCAL_DIRECTORY_NAME
In case of issue with ‘too long filename’ :
git config --system core.longpaths true
Delete a branch (local and remote) :
git branch -d branch_name git push origin :<branch_name>
Rebase a branch (local and remote) :
rebase branch feature1 to develop
git checkout feature1 git pull git rebase develop git pull git push origin feature1
To merge branch AAA into develop :
git checkout AAA git pull git checkout develop git pull git merge AAA git status git push
This will merge the branch AAA into develop
To do the same without auto commit, add “–no-commit”
GitHub – ansible-role-nginx: Ansible role to install and manage nginx configuration PHP 5.6 on CentOS/RHEL 7.2 and 6.8 via Yum | Webtatic.com
To ignore SSL certificate :
One shot :
To disable :
Change Git remote URL :
https://help.github.com/articles/changing-a-remote-s-url/
Change remote origin:
To delete a tag :
Force git to overwrite everything on pull? (back to origin)
To retrieve the latest tag :
git 2.x on CentOS 6
Splitting a subfolder out into a new repository : https://help.github.com/articles/splitting-a-subfolder-out-into-a-new-repository/
check https://stackoverflow.com/a/69356543 in case of error
Update only one file to a specific commit :
to retrieve current branch :
Commit all files recursively :
in ~/.gitconfig
in ~/git.store :
create git repo from dir with existing sources :
connect to gitlab using SSH key
* Generate SSH key on client machine
* Add (public) key to gitlab profile (~/.ssh/id_rsa.pub by default)
* edit git config on client
* test the connection
* checkout using SSH :
Issue git ‘SSL connect error’
update openssl & nss :
https://stackoverflow.com/questions/30678583/centos-6-6-curl-returns-error-when-connecting-to-some-ssl-site
Reset repo :
cheat sheet : http://gitcheats.com/
Limit
git clone https://github.com/atom/atom -b v1.0.2 –depth=1
Revert a merge :
Remove large file from git history
list large files, with size > 2Mb and not present in the last commit:
git error > git refusing to merge unrelated histories
Ensure shadow clone is not used to clone source before merge
Enable debug mode :
Enable color
Undo ‘git add’
or
to unstage all changes
CentOS7 | Install Git 2.x
yum remove git* -y
yum -y install https://packages.endpointdev.com/rhel/7/os/x86_64/endpoint-repo-1.10-1.x86_64.rpm
yum install git -y
Overwrite git author :
https://stackoverflow.com/a/30737248
Setup proxy for Git :
Edit git config :
Error “RPC failed; curl 56 GnuTLS recv error (-110): The TLS connection was non-properly terminated.”
Install Git from sources
Download sources
Install dependencies (RHEL)
Build sources
Git repo cleanup
Migrate to LFS :
https://support.atlassian.com/bitbucket-cloud/docs/use-bfg-to-migrate-a-repo-to-git-lfs/
Repo Cleaner:
https://rtyley.github.io/bfg-repo-cleaner/
Install Gitv2 on RHEL/CentOS 8
https://linuxconcept.com/how-to-install-git-on-rhel-8-red-hat-enterprise-linux-operating-system/
Unix Store git credentials
Create a tag from an existing commit hash
and then push tags: