Git Commands

Here are the few Git commands which helps you more productive in your projects. See below.

Git Clone & Pull Repository
git clone repository(Example – git clone https://gitlab.com/gitlab-org/gitlab.git))

Pull the latest code from repos: git pull <REMOTE> <name-of-branch>

Git Push
Make a new branch: git checkout -b <name-of-branch>
Check Status or Differnce: git status, git diff

Add files and commit
git add .
git commit -m “COMMENT TO DESCRIBE THE INTENTION OF THE COMMIT”

Push into repos: git push origin <name-of-branch>


Additional commands

Check git installation is done: git –version

Add your Git username and set your email: git config –global user.name “YOUR_USERNAME”

Check info is correct: git config –global –list

Delete all changes in the branch that is not staged: git checkout .
Undo the most recently added, but not committed, changes to files/folders: git reset .

Undo most recent commit: git reset HEAD~1

Merge a branch with master:
git checkout <name-of-branch>
git merge master

Hope you got a clear understanding about how to handle Git more effectively.

Be the first to comment

Leave a Reply

Your email address will not be published.


*