Git Basic Commands

Here comes the basic git commands which i have been using in my day to day project :
1.Cloning the repo :Receives a version of every file for the history of the project data that the server has.  
git clone tlrepo@code.ttldev:TracsWebFunctionalTests 

2.Checkout :Checks out files, checks out commits, and checks out branches. git checkout git checkout mastergit checkout TravelEssentials.cs 

3. Status :What have you changed but not yet staged? And what have you staged that you are about to commit?
git status

4. Add To begin tracking new files, to stage files, and to resolve merge-conflicted files.
git add AddAnotherJourney.cs.

5.Diff :Exact lines added and removed
git diff (To see what is still unstaged)
git diff –staged  (To see what you’ve staged that will go into your next commit)


6. git clean
git clean –f (Removes untracked files)

7. To delete the last commit before push
git reset –soft HEAD~1 ( delete the commit but it will leave all your changed files) 

8.



/c/ttl/TracsWebFunctionalTests(4.15)
$ git commit
On branch 4.15
Your branch is up-to-date with ‘origin/4.15’.

Changes not staged for commit:
        modified:   TracsFunctionalTest/Tests/AmendJourney/AmendJourneyTest.cs

Untracked files:
        Class2.cs

no changes added to commit

/c/ttl/TracsWebFunctionalTests(4.15)
$ git clean
fatal: clean.requireForce defaults to true and neither -i, -n nor -f given; refused

/c/ttl/TracsWebFunctionalTests(4.15)
$ git clean-f
git: ‘clean-f’ is not a git command. See ‘git –help’.

/c/ttl/TracsWebFunctionalTests(4.15)
$ git clean –f
Removing Class2.cs

/c/ttl/TracsWebFunctionalTests(4.15)
$ git commit
On branch 4.15
Your branch is up-to-date with ‘origin/4.15’.

Changes not staged for commit:
        modified:   TracsFunctionalTest/Tests/AmendJourney/AmendJourneyTest.cs


9. git log
      git log -p –word–diff
      git log –stat

      git log –pretty=format:”%h – %an, %ar : %s”

Option Description
-p Show the patch introduced with each commit.
--word-diff Show the patch in a word diff format.
--stat Show statistics for files modified in each commit.
--shortstat Display only the changed/insertions/deletions line from the –stat command.
--name-only Show the list of files modified after the commit information.
--name-status Show the list of files affected with added/modified/deleted information as well.
--abbrev-commit Show only the first few characters of the SHA-1 checksum instead of all 40.
--relative-date Display the date in a relative format (for example, “2 weeks ago”) instead of using the full date format.
--graph Display an ASCII graph of the branch and merge history beside the log output.
--pretty Show commits in an alternate format. Options include oneline, short, full, fuller, and format (where you specify your own format).
--oneline A convenience option short for --pretty=oneline --abbrev-commit.





Advertisements
This entry was posted in GIT, Learning. Bookmark the permalink.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s