Git কমান্ড চিটশিট

Git আপনার ফাইলের পরিবর্তনগুলো রিপোজিটরির মধ্যে কমিটের একটি সিরিজ হিসেবে ট্র্যাক করে। এই কমান্ডগুলো দৈনন্দিন কাজের ধারা কভার করে: রিপো তৈরি, কাজ সেভ, ব্রাঞ্চ, মার্জ এবং রিমোটের সঙ্গে শেয়ার করা। শেখার সময় শিটটি খোলা রাখুন।

আপডেট করা হয়েছে:

কমান্ডকী করে
git initCreate a new, empty Git repository in the current directory.
git cloneDownload a remote repository and its full history to your machine.
git statusShow changed, staged and untracked files in the working tree.
git addStage changes (files) to be included in the next commit.
git commitRecord staged changes as a new commit with a message.
git logDisplay the commit history of the repository.
git diffShow unstaged or staged differences between states.
git branchList, create or delete branches in the repository.
git checkout / switchSwitch branches or restore files (switch is the modern command).
git mergeJoin another branch's history into the current branch.
git rebaseReapply commits on top of another base commit, rewriting history.
git pullFetch from a remote and merge the changes into the current branch.
git pushUpload local commits to a remote repository.
git stashTemporarily shelve uncommitted changes to reapply later.
git remoteManage the set of remote repositories you track.

নোট

সচরাচর জিজ্ঞাসা

merge ও rebase-এর মধ্যে পার্থক্য কী?
merge দুটি প্যারেন্ট বিশিষ্ট একটি নতুন কমিট দিয়ে ইতিহাস জুড়ে দেয়। rebase আপনার কমিটগুলোকে অন্য ব্রাঞ্চের ওপর পুনরায় চালায়, যাতে লিনিয়ার ইতিহাস তৈরি হয় কিন্তু কমিট ID লেখা আবার হয়।
কোনো কমিট ফিরিয়ে নেব কীভাবে?
'git revert <কমিট>' ব্যবহার করুন পরিবর্তন বাতিল করে এমন একটি নতুন কমিট যোগ করতে (নিরাপদ, শেয়ার করা ইতিহাস থাকে)। 'git reset' ইতিহাস লিখে দেয়, শেয়ার ব্রাঞ্চে এটি ব্যবহার করবেন না।
git pull ও git fetch-এর পার্থক্য কী?
fetch রিমোট থেকে কমিট ও রেফারেন্স ডাউনলোড করে কিন্তু আপনার কাজের গাছে হাত দেয় না। pull আগে fetch করে তারপর বর্তমান ব্রাঞ্চে সেই পরিবর্তনগুলো মার্জ বা রিবেস করে।
git stash কবে ব্যবহার করবেন?
stash কমিট না-করা পরিবর্তনগুলো অস্থায়ী সরিয়ে রাখে, যাতে আপনি পরিষ্কারভাবে ব্রাঞ্চ বদলাতে বা পুল করতে পারেন, পরে 'git stash pop' দিয়ে ফিরিয়ে আনতে পারেন।