1. Install git
sudo apt install git2. create file .ssh
sudo mkdir /home/your_user/.ssh 3. On folder .ssh run next command, (enter and enter doesn't write anything).
ssh-key4. copy content on file id_rsa.pub
cat /home/your_user/.ssh/id_rsa.pub5. Open in your browser GitHub or GitLab
GitHub: https://github.com/settings/keys -> New SSH keyGitLab:https://your_ip_or_hostname/profile/keys --> Add and SSH Key
6. Clone branch or specific branch
Any branch:
git clone <remote-repo>Specific branch:
git clone --single-branch --branch <branchname> <remote-repo>8. Discard unstaged changes
git stash9. Git Checkout Specific file
git checkout <branch_name> -- <paths>10. Override comment in commit
git commit --amend -m "My_new_comment"11. Remove local commits
git reset --hard origin/<branch_name>12. To rollback to commit
git reset --hard sha1_id13. Create GitHub Branch from Commit
Clone the Repository:
git clone https://github.com/your-username/your-repository.gitcd your-repository
Find the Commit Hash:
git logCreate a New Branch:
git checkout -b new-branch-name commit-hashPush the New Branch to GitHub:
git push origin new-branch-name14. Pull All Branches Automatically
To configure your Git repository to automatically track all remote branches, you can set the following:
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
git fetch origin
This ensures that all remote branches are fetched and mirrored locally.
15. Long path file:
git config --system core.longpaths true
No comments:
Post a Comment