How to update the GIT remote repo
Update to the new repo
git remote set-url origin <new repo>
Check the current origin
git remote -v
After we moved to the new repository… run this command to clean up deleted branches
git fetch -p
Update to the new repo
git remote set-url origin <new repo>
Check the current origin
git remote -v
After we moved to the new repository… run this command to clean up deleted branches
git fetch -p
ไปทำอีท่าไหนไม่รู้ ตอนpush code ขึ้น git แล้วขึ้น Error มาตามด้านล่าง current branch does not match the name of your current branch . เช็คดูดีๆ อ้าว feature branch ไปชี้ที่ master นี้..ไม่ใช่ละ โอเค…ปัญหานี้แก้ได้ ไม่ยาก แค่เราต้องปลด branch ที่ผูก แล้วผูกด้วย remote branch ที่ถูกต้อง โดยเริ่มทำการปลด upstream branch ก่อนตามคำสั่งนี้ คราวนี้ local branch เราก็จะไม่ผูกกับ remote แล้ว ต่อไปก็ทำการผูกกับ remote ลอง pull & push ก็จะได้ปกติ
Run this example command below in a command line In this example, is to upgrade the version by specify the version @<version>
คือเดี่ยวนี้มีโปรเจคย่อยเยอะแยะ เกือบๆสิบโปรเจคอยู่ใน folder เดียว เราอยากจะ run command เดียวแล้ว git pull โปรเจคทั้งหมดภายในคำสั่งเดียว ทำยังไง ก็ทำไงแบบนี้ไง จะรันผ่าน command line หรือใส่ sh file ก็ได้นะ
บางครั้งอาจจะเคยเจอว่าเครื่องของเราไม่สามารถ git pull อะไรได้ ขึ้น warning บอกว่า .ssh/known_hosts อยู่แก้ เราสามารถดู line ที่ขึ้น error ได้ ดู host แล้วใช้คำสั่ง ssh-keygen -R <host> เพื่อลบสะ
เมื่อเราต้องการสร้าง tag ที่เป็นเหมือน label แปะไว้สำหรับ version ใด vesion หนึ่ง เช่น เมื่อเรา deploy prod ที่ version ไปแล้ว เราอาจจะอยาก tag เพื่อให้รู้ว่า deploy prod ที่ version ไหน นี้คือคำสั่งสำหรับสร้าง tag Create a tag For examle หลังจากลอง list tag ออกมาโดยใช้คำสั่งนี้ List tags และเมื่อต้องการ push tag ที่หา remote ใช้คำสั่ง Push tags to remote
ใน git ปกติแล้วเราต้องการลบ branch สามารถใช้คำสั่งด้านล่างได้เลย แต่ถ้าได้ข้อความจากgit บอกว่า the Branch xxxx is not fully merged. เราก็ต้อง -D แทน -d เพื่อเป็นการ force delete error: The branch ‘xxxxxx’ is not fully merged. References: How to Delete a Git Branch Both Locally and Remotely