Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

How to Work With Git From CLI in Win*

DZone's Guide to

How to Work With Git From CLI in Win*

DevOps can't run without Git, and many enterprises are married to a Win* stack. This how-to will get you running Git from CLI like clockwork.

· DevOps Zone
Free Resource

The DevOps Zone is brought to you in partnership with Sonatype Nexus. The Nexus Suite helps scale your DevOps delivery with continuous component intelligence integrated into development tools, including Eclipse, IntelliJ, Jenkins, Bamboo, SonarQube and more. Schedule a demo today

It’s very important to know the commands behind the UI in Visual Studio; in this post, I just explain the basics that you need to work with Git from the command line:

  1. Set the global settings, but first display its value.

    git config –global -l

    N.b. If there is no set value, it will tell you "no such a file," but if there is data it will be displayed as the following:

    git config --global -lIf you open the user folder, you can see ."gitconfig," and if you open the Visual Studio's global settings, you will find that this info has been set there too..gitconfig

  2. I can edit this file using VIM, the most famous of all *nix editors. 
    git config --global -e To quit, type :q +enter; you can key "i" to enter text and save by pressing "ESC" and :wq and enter, this will commit the message you typed. In your current state, to just come out without committing, you can do :q
  3. git config --global -e edit

    If you open the file without a proper shutdown, it will create a swap file which you can’t open again smoothly. You just need to delete that swap file or close the file as mentioned before.

    .gitconfig.swp

  4. Navigate to the working directory and type:

    git init
    git clone https://github.com/youraccount/rep
    This will copy all files locally. The vodeblock below carries basic references for adding new files, committing, changing the branch, and publishing changes:

    # Add new files
    git add .
    
    # Get status
    git status
    
    # Commit
    git commit -m ”your commit message”
    
    # Change branch
    git checkout branchName
    
    # Push
    git push https://github.com/youraccount/rep

The DevOps Zone is brought to you in partnership with Sonatype Nexus. Use the Nexus Suite to automate your software supply chain and ensure you're using the highest quality open source components at every step of the development lifecycle. Get Nexus today

Topics:
git ,devops ,visual studio

Published at DZone with permission of Mohamed Radwan, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}