1. Install git
sudo apt install git
2. create file .ssh
sudo mkdir /home/your_user/.ssh
3. On folder .ssh run next command, (enter and enter doesn't write anything).
ssh-key
4. copy content on file id_rsa.pub
cat /home/your_user/.ssh/id_rsa.pub
5. 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 stash
9. 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_id
13. 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 log
Create a New Branch:
git checkout -b new-branch-name commit-hash
Push the New Branch to GitHub:
git push origin new-branch-name
14. Long path file:
git config --system core.longpaths true
No comments:
Post a Comment