DEV Community

Tracy K
Tracy K

Posted on

#Git Workflow

File Creation and Working directory

*From your local device, locate and open git to access git bash
*From the git bash command execution area, enter the command cd to take you to the home path.
*Then enter command cd Desktop to navigate to the desktop folder.

*Use the commands below to create a new folder *
*mkdir my-first-project. This opens a new folder. There are two options in naming:
*use hyphens to separate the name not spaces
*write the folder name under quotation marks e.g 'my first project'. This prevents generation of three individual folders instead of one.

*cd my-first-project. It takes you inside your created folder hence, this will be your working directory.
*touch filename.extension. This creates a new file that is specific to the type of extension you want. For example, data.xlsx for excel, script.py for python and notes.txt for text file.

  • One file creation, you data edit and add content in your respective created file above.

GitHub repository creation

*Open your browser and log into github.
*From the home page, on the top right locate (+) icon and select new repository to create a new repository.
*Give your repo an appropriate name, add a description which should be clear and precise but not mandatory.
*You can make the repo either public or private depending on your preference. Public repo is visible to everyone while private repo is only visible in your account.

Staging and commit

To stage your files, use commands below
*from the working directory in git, use the following commands:
*git init to initialize your git
*git add . to move your files e.g script.py from working directory to the staging area. The staging area is where your files stay before they get committed.
*git commit -m 'initial commit' to move your files from the staging area to the local repository. Local repository is a hidden repo that is managed by git.

*Go back to github , locate your created repo, open the repo and find the green button written 'code', click on the drop down symbol and copy the link that is under https.

*git remote add origin github_https_link'. This connects a remote repository hosted on GitHub to your local Git repository on your PC.
*git push origin main to push your files from your local computer to your github repository

Top comments (0)