Translate

Showing posts with label Git. Show all posts
Showing posts with label Git. Show all posts

Wednesday, April 4, 2018

How to edit a commit message









what you need to do is go to your repository  and type this in your command line:



  git commit --amend



Then in your text editor you can put the new commit message.

Good Luck And Happy Hacking!!!

Tuesday, March 13, 2018

Git push force









Sometimes, it is  necessary to performed a push force in our repositories, but you need to be really careful because this action will overwrite all, so you need to know what you are doing.

This is the code:

git push -f <remote> <branch>

e.g
git push -f origin my_new_feature

Friday, September 2, 2016

Git: How to rename a branch


To rename a branch created locally, what you need to do is:


  • First, go to the branch you want to rename:
git checkout my_branch_1
  • then, rename your current branch by typing the following command:
git branch -m my_new_name_branch_2



if you display all branches (git branch) you will in green color the new name of your branch

GIT: How to delete last commit?



To undo or delete a commit previously done, just type the following command in your console:


git reset --hard HEAD~1

Sunday, June 26, 2016

How to install GIT on Ubuntu from command line


To install GIT on Ubuntu what you have to do is following these steps:

  1.  Type this command on your terminal:

sudo apt install git



      2. Add your configuration:


git config --global user.email "your_email@example.com"
git config --global user.name "Your Name"

Tuesday, February 9, 2016

The most usefull GIT Commands






These are the most common GIT commands



  • Create an empty repository
  
      git init
   
  • Staging your changes
  
     git add
   

    • If you are your  root directory , I mean myapplication/ you can use the paramter -A to stage all changes in one execution.
  
     git add -A
   

  • Putting you changes in your local repo
                  git commit
  
    git commit
   
    • If you want to add a message in your commit you can use the parameter  -m
  
   git commit -m "login fixed"
   

  • Switching between branches
  
   git checkout develop
   
  • Creating a new branch
  
   git checkout -b MyNewBranch
   


  • Adding new remote
  
   git remote add origin https://github.com/plataformatec/devise.git
   

  • Saving your changes to the remote repo  
  
     git push origin develop
   

  • Pull down new changes


  
     git pull origin develop
   

Wednesday, October 28, 2015

How to remove remote origin URL from git repository








To remove a remote URL from GIT, you must  use the command git remote remove.

Here is an example:
  
     git remote remove origin
  
or you can use:

  
    git remote rm origin
  

Thursday, September 3, 2015

How to rename a tag in GIT






In this post, I will teach you how to rename a tag in git.

Actually, it is pretty easy.


I am going to rename the tag called myOldTag to myNewTag.

Step 1: we create an alias called "myNewTag"
  
     git tag myNewTag myOldTag

  

Step 2: we delete the myOldTag  tag locally
  
     git tag -d myOldTag

  

Step 3: we tell to git repository that myoldTag has been deleted
  
     git push origin :refs/tags/myOldTag

  

Step 4: we save the changes on GIT
  
     git push --tags