Skip to main content

Github - Basic commands

Github - Basic commands


The windows portable git will work in most cases when you are working on Windows OS. Initiate the git in the current folder. Right click and open the git bash. 

Opening the git client

If on command line, git init should work.

git init

Cloning the entire remote repo to a local location with root folder name as the repo name.


git clone https://github.com/rapidsailor/ShellScripts

Now navigate to the the newly created folders. Use cd command as needed. Make some code changes. 

To verify the changes and status


git status

Add any new files to the repo or add the changes to existing files.


git add

Commit the changes

Commits all the changes to the remote repo. This may ask for your github user and password.

git commit -m “comment for check-in”

Note : Any file changes to be done using the vi, ( i for insert mode, put in some comments. All the lines starting with # will be ignored. put some new lines without # as starting char.) esc for going to command mode. :wq for saving and exiting and :q! for not saving.

Push the changes to remote master branch.


git push origin master (this will push the data to the master branch of the remote repo)

Pull the latest from the remote location.


git pull (Run this in the project folder)

Branching out and creating new branches.


View all the current branches


git branch

Create new branch. Below command will checkout the original code to new branch called branch1. 

#git checkout -b branch1 (-b is used to create a new branch. To switch to an existing branch, remove -b) After any code changes , run the following.
 

Basic steps during a standard session


git add

git commit -m “comment for check-in”

git push -u origin branch1.


Setting the git configs


git config –global user.name “your full name”

git config –global user.email “your email”

Comments

Popular posts from this blog

Public private key based login to Unix computer

Public private key based login to Unix computer We know that we can login to a Unix system in several ways. One drawback with username password mode is that there will be requirement to update the password frequently. In such cases, we go for the public key based login.  Required software 1. Putty and puttygen Putty can be downloaded from the download page of  https://www.putty.org/ The downloaded zip contains both putty and puttygen. 2. Winscp This is an optional software which gives a window when dealing with ssh, ftp, sftp connections. This can be downloaded from their official site. https://winscp.net/eng/download.php How it works In the public key based login, we will generate a public key and corresponding private key pair. We can optionally protect the private key using a password so that if someone gets your private key, they wont be able to put it into real use [The secret would be needed for loading your private key to the ssh client]. Process Create the public - private k

PDF files : Merge pdf files into one , extract the pages into new one

 Today, we will take a look into he pdf file management. Many a times we come across situations where  1. We have to extract certain pages of a large pdf file. 2. We have merge several pdf files into a single pdf file. We are covering the basic usage below. We are using Ubuntu Linux for this exercise. Merge several files into a single file 'Pdfunite' is the utility that I will be using today. In my example, I have 3 input files (pdf1.pdf, pdf2.pdf, pdf3.pdf)   Place all the files to be merged in a folder. Use the terminal to navigate to the folder. Execute the command as below: pdfunite is the utility, then we list out all the files in the sequence it has to be added to the resulting file. The last name is the name of the resulting file. The file will be created by the utility. pdfunite pdf1.pdf pdf2.pdf pdf-result.pdf  Now you can see that there is a new large file created using the given input pdf files.  Extract certain pages from a PDF file I am using the 'pdfseparate&#

Linux - How to find all the files that contains a given string

Linux - Find all files that contains a given string. In order to find all the files that contains a given string, we can make use of several commands. One of the simplest option is to use the grep command. grep -R '/path/to/theFiles/' -e 'pattern-to-search' With this execution, grep will go through all the files in the provided location recursively(since we gave -R option) and look for the string-pattern to look for. Then, it will provide a list of files that contains our given string-pattern.