-
Gennerate SSH Key ssh-keygen -t rsa -b 4096 -C [email protected] ssh-keygen -t rsa -b 4096 -C [email protected]
-
Remove ssh: rm -f ~/.ssh/id_rsa*
-
View ssh: cat ~/.ssh/id_rsa.pub
-
Check if exists: ls -al ~/.ssh -Adding your SSH key to the ssh-agent eval "$(ssh-agent -s)" ssh-add ~/.ssh/id_rsa https://help.github.com/articles/connecting-to-github-with-ssh/
-
Fork project git clone link
Git global setup git config --global user.name "Tran Dang Doanh" git config --global user.email "[email protected]"
Create a new repository git clone ssh://[email protected]:30001/doanhtd/cnafis.git cd cnafis touch README.md git add README.md git commit -m "add README" git push -u origin master
Existing folder cd existing_folder git init git remote add origin ssh://[email protected]:30001/doanhtd/cnafis.git git add . git commit -m "Initial commit" git push -u origin master
Existing Git repository cd existing_repo git remote rename origin old-origin git remote add origin ssh://[email protected]:30001/doanhtd/cnafis.git git push -u origin --all git push -u origin --tags
git remote -v => origin link (fetch) origin link (push)
Lưu thay đổi, chuyển qua branh khác git stash git checkout correct-branch git stash pop
Xem thay đổi (chưa đc add) của những file hiện tại git diff Xem thay đổi (đã được add, chưa commit) git diff --cached git show --pretty="" --name-only d4f6c2c
-
Neu da checkout voi repo fork thi set lai url ve repo master git remote set-url origin [email protected]:USERNAME/REPOSITORY.git
-
Và cuối cùng add origin cho sub-project git remote add longlv sub-project-link
-
Check lại danh sách các remote git remote -v ==> origin super-project-link (fetch) origin super-project-link (push) longlv sub-project-link (fetch) longlv sub-project-link (push)
-
Commit git checkout develop git pull origin develop git checkout -b oLeVanLong_164392 git rebase develop git status git add . git commit -m "Bug #164390 [BookHodai] Fix bugs feedback" git commit --amend --no-edit git push long oLeVanLong_164390
-
Replace Commit git status git add . (git reset -> undo add) git commit --amend -m "Bug #164390 [BookHodai] Fix bugs feedback"
git push long oLeVanLong_164390 -f
-
Gop 2 commit git status git log --oneline -5 // Xem 5 log dau tien git reset HEAD~ // xoa commit trung dau tien git add . git commit --amend --no-edit git status // Se thay cac file thay doi cua commit da xoa git branch git push long oLeVanLong_164390 -f
-
Pick commit git cherry-pick 453e458 // add commit to my branch // Remove cherry pick git stash git reset --hard HEAD^ git stash pop -Delete branch
- Remotely
- git push origin --delete longlv_Ticket1
- Local
- git branch -d <branch_name>
//Rename banch
- Rename your local branch. If you are on the branch you want to rename:
git branch -m new-name If you are on a different branch:
git branch -m old-name new-name 2. Delete the old-name remote branch and push the new-name local branch.
git push origin :old-name new-name 3. Reset the upstream branch for the new-name local branch. Switch to the branch and then:
git push origin -u new-name
-Submodule git submodule add Now when you clone the project you simply need to init and update the submodule
git submodule init git submodule update Git 1.8.2 features a new option --remote git submodule update --init --recursive or git submodule update --remote --merge