Common Git Commands

مؤشر الاسهم الان These are some common and useful commands to help you along with using Git. This post will grow as I think of more to add for future reference. Also, feel free to recommend any that you think are relevant.


Getting started with Git

go to link These are the absolute most common commands you'll use with Git. I've listed them in the order that you'd usually use them.

Step 1 - Clone a Git repository

كيف تكسب المال الجيد بسرعة What this means is that you are copying someone else's repository down to your computer. This is fundamental to the way Git works. Each time a Git repository is cloned, literally the entire repository including all change history is copied to your computer. This is why it's referred to as "distributed source control".

الفوركس النيوزلاندي git clone After you have cloned the repo, you need to cd into the repo folder

برنامج تجارة الخيارات الثنائية cd repo-name

Step 2 - Save your changes Making and saving changes to your repo is a three step process. then.

كسب المال بملء الاستطلاعات First you need to edit the file(s) and save them. Next, to see which edited files are ready for add/commit/pushing, you check your repository status.

enter site git status

تجارة نت الذهب Next, you need to add it (a.k.a. "stage" it) git add .

source You can also add individual files by using the filename instead of the "."

بيع اسهم شركة بوان git add filename.extЩѓЩЉЩЃ-Ш§ШґШЄШ±ЩЉ-Ш§ШіЩ‡Щ…-ШЁШ§Щ„ШЁЩ†Щѓ-Ш§Щ„Ш±Ш§Ш¬Ш­ЩЉ Next, commit the staged changes to your local repository copy

source git commit -m "Made XYZ changes" The -m flag indicates that you want to add a commit message, which goes inside quotes

خيار ثنائي حساب تجريبي مجاني Lastly, since you have so far only been committing changes to the repository on your local computer, you'll need to push all those commits back up to the master repository.

git push

It's important to understand these fundamental concepts of Git before getting started. However, don't be afraid/shy/embarrassed to ask coworkers, or even the community (i.e., this blog) for help. Things can certainly get more complex than these few commands. Fortunately, there is a user-friendly-ish Git manual to help if you can't find a live person.

Merging conflicts

If get the message after trying to pull "Automatic merge failed; fix conflicts and then commit the result.", use this to launch your mergetool

git mergetool

Merging branches

In this scenario imagine you've created a branch locally to work in isolation and you want to merge your changes back into the master branch. What you need to to is simply checkout the branch you want to merge your changes into. Then run git merge to define which branch to merge into the branch you just checked out.

git checkout master
git merge branchname

More reading

Add color to UI

git config color.ui true

Diff files against head/remote/origin/branch/etc.

For comparing a local file against the latest in the repository (source)

git difftool HEAD~50 path/to/file

Get info about your repository

This is where you can find out information about your repository including branch and origin settings.

vim .git/config

Checkout a tracked remote branch

Remember to run git fetch first or you might get this error: "fatal: git checkout: updating paths is incompatible with switching branches". Using -b will create a new branch named "haml" linked to the remote branch of the same name.
additional reading []

git fetch
git checkout --track -b haml origin/haml

Show all remote branches available for checkout

This is useful for finding out the exact branch name when checking out a new remote branch.
additional reading []

git remote show origin

View unpushed Git Commits

This is the only way I know of seeing the difference in state between your local repo and the remote. If you want to see the files of each Git commit, check out the command below.

git log origin/master..HEAD

Show files changed in a Git commit

Replace the string below (eeeb63e29ff62c0f06bdcc05588e941a2ff3467d) with your own commit id.

git show eeeb63e29ff62c0f06bdcc05588e94

also, if you want to only see a list of file names for each commit:

git show --pretty="format:" --name-only eeeb63e29ff62c0f06bdcc05588e94

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>