Best practice to follow on git and github

Some basics: linux

Note: <> just used to differentiate the file for understanding:

  1. ls -list the file

  2. mkdir <folder name> - creach the file name

  3. touch <file name> - create the file

  4. code . - take to vs code

  5. vi <filename >- open the vim editor - Don’t dive deep into vim editor

    1. There are two mode Edit mode and command mode

    2. You can press Esc to enter cmd mode to give command like insert delete update and so on 

    3. i - for insert a text in a file O, o move the cursor above and below

    4. :wq - write and save the file

    5. These are the basic about vim editor but don’t spend too much time on this use other editor for faster progress and so on

    6. We can directly open the file and made the changes

    7. Vim is fun to learn

  6. cat <file name > - show what are there in that file

  7. rm -rf <file/folder name> -remove the the file or folder from the current directory

  8. cd - change the directory(where we are working and our file path)

  9. cd .. go back the previous folder in a directory

Git configuration

  1. git config --global user.name “[firstname lastname]”

  2. git config --global user.email “[valid-email]”

  3. git config --list(Will give your configuration list)

Working with git and github

  • git init- initialise the git on the folder.

  • git status to know which branch your are working

  • Always create a new branch and start working

  • git branch <branch name> - create a branch

  • git checkout <branch name>  -switch to branch

  • git add . for adding all file to staging

  • git add <file name> for single file

  • git commit -m “Your msg like what changes you have made”

  • git log - show how much commit you did

  • git restore –staged <file name> - if you add the file by mistake it go back and remove the add

  • Check git log -it show the commit

  • git log give the list of commit and id

  • git reset  <id> - remove the commit before the commit id

  • git stash - changes you make go back to stage

  • git stash pop - changes come back again

  • git stash clear - back in the stage is clear

Ideal scenario:

  • Create a repository in your account or if you are working in an open source repo fork it and have that repo in your github account that how you can change or contribute to the folder.

  • After that clone the repo

  • And create a branch and start working the feature(if it's another person repo create branch , if it's yours main start working on the main.you can also create branch and start working on your repo for learning purpose and keep track what feature you are working on.

  • Whenever you are working give the (git pull) on main to get the latest version of the repo

  1. git fetch –fetch –all –prune 

  2. git reset –hard upstream

  3. git push origin main/master

                or 

  1. git pull upstream main

  2. git push origin main/master

or

select fetch upstream in the github ui to update with main

Make sure you are in the main branch

  • git pull - to pull the new changes in main and give 

  • git merge <branch name > after that create a pull request once your code is reviewed reviewer will merge.

  • If it is the same issue, many people are working together, conflict may occur, resolve the conflict by discussion and so on and search the internet on how to solve it. 

If you are working on your own repo direct pull from old and push from new changes it will be straight forward.

Where i wasted time maybe you can waste:

Don’t learn so much about vim it just editor you can use vs code or notepad

Whenever you push your changes 

  • Github username and password not going to work so you have generate a token

  • Path - github - settings  - developer setting - personal access token - new token - generate token – give access to the repository - token will generate save it wherever you want 

  • Whenever it asks for a user name, gives the user name and password, pastes the code it is not visible and press enter will push changes local to the repository.


you can also checkout my git hub

Thanks
Mukeshraj M

Comments

Popular posts from this blog

Deep learning with TensorFlow

Image classification(Fastbook notebook_2)