Category: TIPS

Using the Screen command

Screen command benefits

  • Can be used to launch multiple shells from a single SSH session.
  • Detach and re-attach from multiple ssh session.
  • Running process which can take more time and need session to be kept alive.
  • To keep the session alive without any network disruptions.

The command to create a screen session is

screen -t <screen name> -S <socket file name>

To detach a screen session

ctrl+a + d

To list the screen sessions

screen -ls

To reattach the screen session

screen -r <pid from list>

Git Hacks

Whenever you do git pull and you find some files modified locally as part of build and want to overwrite it with the contents in the git repository.

git checkout HEAD^ file/to/overwrite
git pull

To checkout a new git branch and to create a new git branch and checkout

git checkout <branch>

git checkout -b <branch>

To delete a remote branch and local branch

git push –delete origin bugfix/
git branch -d bugfix/

To copy a directory without its history and add as a new folder in git

cp -R old_dir new_dir

git add new_dir

git commit -m "first revision of new_dir's copied files"

Creating a diff file

git diff > 1.patch

Applying a git generated patch file

git apply 1.patch

Page 1 of 6
1 2 3 6