Git key point part II

Checkout out different version on your snapshot is don’t using the git log –oneline , example if there are many commit for different files , simple check the hash code for each commit using git log –oneline and then checkout the exact version you want  . Example git checkout 823kw23 Messenger.Java , then check your editor or IDE NOTE : Nearly everything about the Git is to have a safe history of project



When you want to undo an entire commit from your commit history (telling git to keep a safe version of your project ) use git revert <Commit>

Example : One of your team make a commit and leads to bug , fixing that will be to remove the commit and not to remove the file, using git revert<commit>

Difference between Git revert and Git reset .

  1. Revert doesn’t change the project history

Reset does

  1. Git revert  can be use for an individual commit

 reset allow you to work with backward commit which may lead to initial point of the project.

  1. Git reset makes you start your project from scratch and undo local changes

Git revert undo  public commit


Suppose you have five files in a single directory which you have all stages using git add . , now you want to make commit to three of the files not all the five files , you only have to make git reset on each file and then make your final commit on the left file , example

git reset FILE A

git reset FILE B

git reset File D


git commit –m’Making commit to File C and E only ’

then use git add fileA – FILEB , FILED

git commit –m’Re staged file A , B AND D’

Now suppose you get your git directory status ( git status )  and you see some untracked files , now you want to remove all untracked files , simply use , now imagine you want to know the file you want to remove , use git clean –n.

Git clean –f  will remove untraced file from the current directory

Git clean –df will remove untracked directory and untracked file

Git clean –xf will remove untracked file from in the current directory and all file your git ignores


Git rebase ( Moving a branch of a new base commit ) which helps in rewriting your project histoy i.e maintain a linear project history

One of the major difference between merging and rebasing is merging

  1. Merge is when you Join two or more development histories together
  2. rebase is when you Reapply commits on top of another base tip
  3. Git init Create an empty Git repository or reinitialize an existing one
  4. Merging result in a three way merge and a single commit
  5. Rebasing result in a fast forward and linear history commit task

Example : You just hire a new developer , you first him to create a branch on the project file

Assuming he created  brack as thus , git brach newDeveloperA, then he need to checkout his new bracnch ( Note all other file in the initial directory remain the same , while he coan continue working on his own file ). Possibly , after he make all his commit using git commit –m’All task is done’, you as the project manager need to checkout each developer branch , assuming you don’t knowing their branch naming, use git branch ( it will show each developer branch ), from there you may check their log and see their commit , if you are okay with developer , you then merge .

  1. Rebase moves the entire feature branch to begin on the tip of the master branch
  2. Pulling in upstream changes with git merge results in a superfluous merge commit every time you want to see how the project has progressed
  3. NOTE : Never rebase commits that have been pushed to a public repository
  4. Fast Forward Merge all Git has to do to integrate the histories is move (i.e., “fast forward”) the current branch tip up to the target branch tip.
  5. 3-way merges use a dedicated commit to tie together the two histories.

Git reflog is a mechanism that keep update of each branch

git remote command lets you create, view, and delete connections to other repositories

git Fetching is what you do when you want to see what everybody else has been working on.

Git push make  changes available to the project maintainer

git branch -D <branch> to delete a branch

git branch -m <branch> to rename a branch


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your 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 )

Google+ photo

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

Connecting to %s

Create a free website or blog at

Up ↑

%d bloggers like this: