Thursday, March 19, 2020

GIT Tips


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 key

GitLab: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.git
cd 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. 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

Integrating Ollama with DeepSeek-R1 in Spring Boot

Are you looking to leverage the power of Ollama and DeepSeek-R1 in your Spring Boot application? This post will walk you through the entire ...